【问题标题】:how can i make the 3 divs move away farther from each other我怎样才能使 3 个 div 彼此远离
【发布时间】:2022-11-28 00:08:21
【问题描述】:

我试图使具有如下图所示的 h1 元素的 div 彼此远离而不是彼此靠近但我似乎不能这样做我不知道是否为每个添加宽度有什么作用.我也尝试添加边距和填充,但它会移动整个页面而不是单独移动每个 div

这是 html 文件中的主要部分

<main>
    <div class="who">
        <h1>Who We Are</h1>
    </div>
    <div class="what">
        <h1>What We Do</h1>
    </div>

    <div class="where">
        <h1>Where We Work</h1>
    </div>
    
</main>

这是 css 文件


*{
    padding:0;
    margin: 0;
    box-sizing: border-box;
}

body{
    font-family: 'Calibri';
    color: #222;
    padding-bottom: 50px;
}

header{
    height:100px;
    display:flex;
    justify-content: space-around;
    align-items: center;
}

ul{
    display:flex;
    list-style-type:none;
    align-items: center;
    justify-content: center;
}

ul li a{
    color: rgb(0,0,0);
    text-decoration: none;
    padding:7px 15px;
    transition: all 0.3s ease-in-out;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    display:inline-block;
}

li a::after{
    content:'';
    display:block;
    height:4px;
    width:0;
    background: #FCAE1E;
}

li a:hover::after{
width:100%;
}

main{
    display: flex;
    height:calc(100vh - 100px);
    align-items: center;
    justify-content: center;
}


.who{
    width: 30%;
}
.what{
    width: 30%;
}
.where{
    width: 30%;
}

here is the image

【问题讨论】:

    标签: html css


    【解决方案1】:

    【讨论】:

    • 我应该将它添加到主分区还是每个分区?
    • 你应该把它添加到主分区
    • 太感谢了
    【解决方案2】:

    /* Just add this in your CSS file */

    h1{ 保证金:30px 0px 30px 0px}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      • 2021-01-04
      相关资源
      最近更新 更多