강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của akwntlsrja59672092
akwntlsrja59672092

câu hỏi đã được viết

Một trại huấn luyện phát triển toàn diện thực sự dành cho những người không chuyên ngành

[그랩마켓] Áp dụng Javascript - 2

질문드립니다.

Viết

·

249

1

<script>
    var products = [
    {
        name : "농구공",
        price : 100000,
        seller : "조던",
        imageUrl : "./images/products/basketball1.jpeg"
    }, {
        name : "축구공",
        price : 50000,
        seller : "메시",
        imageUrl : "./images/products/soccerball1.jpg"
    }, {
        name : "키보드",
        price : 10000,
        seller : "그랩",
        imageUrl : "./images/products/keyboard1.jpg"
    },
];
    let productsHtml = ' ';
    for(var i = 0i < products.lengthi++) {
        productsHtml =
            productsHtml +
            '<div class="product-card">' +
            "<div>" +
            '<img class="product-img" src="./images/products/basketball1.jpeg">' +
            "</div>"
            '<div class="product-contents">' +
            '<span class="product-name">농구공 1호</span>' +
            '<span class="porduct-price">50000원</span>' +
            '<div class="product-seller">' +
            '<img class="product-avatar" src="./images/icons/avatar.png">' +
            "<span>KDY</span>" +
            "</div>" +
            "</div>" +
            "</div>";
    }

    document.querySelector("#product-list").innerHTML =  productsHtml;
</script>
</html>
해당 코드를 작성 후에 아래 사진처럼 나오는데 코드가
잘못된게 있는건가요??
javascriptreact-nativetensorflowexpressreact머신러닝 배워볼래요? nodejsHTML/CSS

Câu trả lời 3

1

Kay potato님의 프로필 이미지
Kay potato
Người đặt câu hỏi

앗 해결했습니다 감사합니다..

0

Kay potato님의 프로필 이미지
Kay potato
Người đặt câu hỏi

<html lang="ko">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Grab-Market</title>

    <link rel="stylesheet" href="index.css" type="text/css">

   

</head>

<body>

    <div id="header">

        <div id="header-area">

            <img src="./images/icons/logo.png"/>

        </div>

    </div>

    <div id="body">

        <div id="banner">

            <img src="./images/banners/banner1.png" />

        </div>

        <h1>판매되는 상품들</h1>

        <div id="product-list">

        </div>

    </div>

    <div id="footer"></div>

</body>

<script>

    var products = [

    {

        name : "농구공",

        price : 100000,

        seller : "조던",

        imageUrl : "images/products/basketball1.jpeg"

    }, {

        name : "축구공",

        price : 50000,

        seller : "메시",

        imageUrl : "images/products/soccerball1.jpg"

    }, {

        name : "키보드",

        price : 10000,

        seller : "그랩",

        imageUrl : "images/products/keyboard1.jpg"

    },

];

    let productsHtml = " ";

    for(var i = 0i < products.lengthi++) {

        productsHtml =

            productsHtml +

            '<div class="product-card">' +

            "<div>" +

            '<img class="product-img" src="images/products/basketball1.jpeg" />' +

            "</div>"

            '<div class="product-contents">' +

            '<span class="product-name">농구공 1호</span>' +

            '<span class="porduct-price">50000원</span>' +

            '<div class="product-seller">' +

            '<img class="product-avatar" src="images/icons/avatar.png" />' +

            "<span>KDY</span>" +

            "</div>" +

            "</div>" +

            "</div>";

    }


    document.querySelector("#product-list").innerHTML =  productsHtml;

</script>

</html>

질문을 다시 드려 죄송합니다.. / 를 넣어줘도 똑같은데
제가 중간에 뭘 잘못한건가요.,.?봐도 다 똑같은거 같은데..
* {
    margin0;
    padding0;
}
body {
    height1500px;
}
#header {
    height64px;
    displayflex;
    justify-contentcenter;
    border-bottom1px solid black;
}
#body {
    height100%;
    width1024px;
    margin0 auto/*부모로 부터 중앙 정렬*/
    padding-bottom24px;
}
#footer {
    height200px;
    background-colorred;
}
#banner {
    height300px;
    background-coloryellow;
}

#header-area {
    width1024px;
    height100%;
    /* margin: 0 auto; */
    displayflex;
    align-itemscenter;
}
#header-area > img {
    width128px;
    height36px;
}
#banner > img {
    width100%;
    height300px;
}
#body > h1 {
    margin-top16px;
}
#product-list{
    displayflex;
    flex-wrapwrap;
    margin-top12px;
}
.product-card {
    width180px;
    height300px;
    margin-right12px;
    margin-bottom12px;
    border1px solid rgb(230230230);
    border-radius12px;
}
.product-img {
    width100%;
    height210px;
}
.product-contents {
    displayflex;
    flex-directioncolumn;
    padding8px;
}
.product-name {
    font-size14px;
}
.product-prise {
    font-size16px;
    font-weight600;
    margin-top4px;
}
.product-seller {
    displayflex;
    align-itemscenter;
    margin-top12px;
}
.product-avatar {
    width24px;
}위 코드는 CSS 코드 입니다 번거롭게 해드려 죄송합니다..

0

grab님의 프로필 이미지
grab
Người chia sẻ kiến thức

img 태그들 뒤에 closing 표시 / 를 넣어주시면 될 것 같아요!

Hình ảnh hồ sơ của akwntlsrja59672092
akwntlsrja59672092

câu hỏi đã được viết

Đặt câu hỏi