about区标题居中不了(设置宽度之后)

来源:4-3 项目作业

可乐_钟无艳

2020-05-15 09:07:23

<div class="about">

    <div class="up">

        <div class="title"><h1>ABOUT</h1></div>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting </br>industry . Lorem Ipsum has been the industry's standard dummy </br>text ever since the 1500s.</p>

    </div>

    <div class="center">

        <div class="about_text1">

            <h3>A WORD</br>ABOUT US</h3>

            <div class="message">

                <p>Praesent dignissim viverra est, sed bibendum ligula congue non. Sed ac nisl et felis gravida commodo? Suspendisse eget ullamcorper ipsum. Suspendisse diam amet.</p>

                <button value="EXPLORE"></button>

            </div>   

        </div>

        <div class="about_img"><img src="images/bb3.jpg"></div>

        <div class="about_text2">

            <div class="num" id="num1">

                <h3>70000</h3>

                <label>Students</label>

            </div>

            <div class="num" id="num2">

                <h3>600</h3>

                <label>Faculty</label>

            </div>

        </div>

    </div>

</div>

/*CSS*/

.about{

width: 100%;

height: 600px;

position: absolute;

}

.about .up{

text-align: center;

width: 100%;

}

.about .center{

width: 100%;

height: 435px;

}

.title{

left: 50%;

padding-bottom: 10px;

border-bottom: #07cbc9 solid 1px;

width: 40px;

}

.title h1{

left: 50%;

text-align: center;

}


写回答

1回答

好帮手慕小尤

2020-05-15

同学你好,1. 使其居中的是父元素中的 text-align: center;属性,则当为.title设置宽度时,使text-align属性失效。则同学可以尝试设置定位,然后先向左移动50%,然后再往回移动宽度的一半,即可实现居中显示。修改后代码如下所示:

http://img.mukewang.com/climg/5ebe2d3409904b5206810272.jpg

2. ABOUT标题下的线,不建议同学使用下边框进行实现,同学可以在HTML中添加一个label标签,然后在css中为其设置背景色,宽度。修改后代码如下所示:

http://img.mukewang.com/climg/5ebe2d9b095346cb05750225.jpg

http://img.mukewang.com/climg/5ebe2d8d097ddd5d04520236.jpg

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!

0

0 学习 · 9666 问题

查看课程