Помогите с html/css

gevorg14

Новичок
Автор темы
7
0
Нужно сделать так,что бы цена и кнопка "Купить" были на одном уровне

HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Морозова</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    
</html>
    <div class="fo0">
    <div class="fon">
    <div class="fon2">
        <img  class = "phot" src = "https://geekufa.ru/images/upload/17115-smartfon-apple-iphone-16-plus-256gb-white_1024.jpg">
        <div class="text"><b>Iphone 16</b></div>
        <div class="text2">  доступен в пяти цветах </div>
        <button class="butt" type= "button" style= "background-color:limegreen; border-color:limegreen ;color:white; width: 70px; height: 25px ">Купить</button>
        <div class="hsen"><b>$971,78</b></div>
    </div>
    </div>
    </div>
    
</body>
</html>
CSS:
.fo0{
    background-color:rgb(209, 209, 209);
    width: 100%;
    height: 100%;
    position: absolute;
    top:0;
    left:0;
}

.fon {
    width: 1500px;
    height: 700px;
    background-color: rgb(209, 209, 209);
    display: grid;
    grid-area:1;
    z-index: 1;
}
.fon2{
    width: 650px;
    height: 550px;
    background-color:rgb(255, 255, 255);
    display: grid;
    grid-area:2;
    z-index: 3;
    display: block;
    grid-area: 2;
    margin:0 auto;
}
.phot{
    width:450px;
    height:400px;
    display: grid;
    grid-area:2;
    z-index: 3;
    display: block;
    margin:0 auto;
}
.text {
    display: grid;
    margin:0 auto;
    display:block;
    text-align:center;
    grid-area:3;
    font-weight: bolder;
    width: 100px;
    height: 20px;
}

.text2 {
    display: grid;
    grid-template-columns: auto;
    grid-area:4;
    font-weight: bolder;
    margin:0 auto;
    display:block;
    text-align:center;   
}
.butt {
    margin-top: 40px;
    margin-left: 325px;
    text-align:center;
}
.hsen{
    color: limegreen;
    width: 300px;
    height: 80px;
    margin-left: 250px;
 
}
 

CapybaraOverlord

Новичок
1
0
HTML:
<!DOCTYPE html>

<html lang="ru">

<head>

    <meta charset="UTF-8">

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

    <title>Морозова</title>

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

</head>

<body>

    <div class="fo0">

        <div class="fon">

            <div class="fon2">

                <img class="phot" src="https://geekufa.ru/images/upload/17115-smartfon-apple-iphone-16-plus-256gb-white_1024.jpg">

                <div class="text"><b>Iphone 16</b></div>

                <div class="text2">доступен в пяти цветах</div>



                <!-- Цена и кнопка в одном контейнере -->

                <div class="price-buy">

                    <div class="hsen"><b>$971,78</b></div>

                    <button class="butt" type="button">Купить</button>

                </div>

            </div>

        </div>

    </div>

</body>

</html>

CSS:
.fo0 {

    background-color: rgb(209, 209, 209);

    width: 100%;

    height: 100%;

    position: absolute;

    top: 0;

    left: 0;

}



.fon {

    width: 1500px;

    height: 700px;

    background-color: rgb(209, 209, 209);

    display: grid;

    margin: 0 auto;

}



.fon2 {

    width: 650px;

    height: 550px;

    background-color: white;

    margin: 0 auto;

    padding: 20px;

    box-shadow: 0 0 10px rgba(0,0,0,0.1);

}



.phot {

    width: 450px;

    height: 400px;

    display: block;

    margin: 0 auto;

}



.text {

    text-align: center;

    font-weight: bolder;

    margin-top: 10px;

}



.text2 {

    text-align: center;

    margin-top: 5px;

    font-weight: bold;

    color: gray;

}



/* Цена и кнопка рядом */

.price-buy {

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 20px; /* расстояние между ценой и кнопкой */

    margin-top: 30px;

}



.hsen {

    color: limegreen;

    font-size: 22px;

    font-weight: bold;

}



.butt {

    background-color: limegreen;

    border: none;

    color: white;

    width: 90px;

    height: 35px;

    border-radius: 5px;

    cursor: pointer;

    font-weight: bold;

}
 
Последнее редактирование модератором:

donateralex

Новичок
15
3
Во первых постарайся писать высоту и ширину в vh и vw, для адаптива очень удобно
Во вторых постановку попробуй делать через блоки flex для начала

html:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Морозова</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="container">
        <div class="container_text">
            <img class="phot" src="https://geekufa.ru/images/upload/17115-smartfon-apple-iphone-16-plus-256gb-white_1024.jpg">
            <p class="name">iPhone 16</p>
            <p class="desc">доступен в трех цветах</p>
            <button class="butt" type="button">Купить</button>
            <p class="price">$971,78</p>
        </div>
    </div>
</body>
</html>

css:
.container {
    height: 68vh;
    background-color: rgb(209, 209, 209);
    display: flex;
    justify-content: center;
}

body {
    background-color:rgb(209, 209, 209);
}

.container_text {
    background-color:rgb(255, 255, 255);
    display: flex;
    justify-items: center;
    flex-direction: column;
}
.container_text > img {
    width: 450px;
    height: 400px;
    margin-top: 0;
}

.container_text > .name {
    text-align: center;
    font-weight: bolder;
}

.container_text > .desc {
    text-align: center;
    margin: 0 auto;
    font-weight: bolder;
}

.container_text > .butt {
    background-color: limegreen;
    border-color: limegreen;
    color: white;
    margin: 0 auto;
    margin-top: 40px;
}
.container_text > .price {
    color: limegreen;
    font-weight: bolder;
    text-align: center;
}
 

MrCreepTon

Неизвестный
Всефорумный модератор
2,347
5,346
постарайся писать высоту и ширину в vh и vw, для адаптива очень удобно
Очень опасное заявление, с vh и vw надо быть очень аккуратным. Пиксели в этом плане гораздо надёжнее + все макеты в пикселях в любом случае пилятся.
 
  • Нравится
Реакции: donateralex

chromiusj

fullstack eblan
Модератор
5,914
4,263
Очень опасное заявление, с vh и vw надо быть очень аккуратным. Пиксели в этом плане гораздо надёжнее + все макеты в пикселях в любом случае пилятся.
а что насчёт dvh,svh?
 
  • Грустно
Реакции: PaddingtonBaby