about图片居中

about图片居中

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Homework</title>

<style type="text/css">

*{

margin:0;

padding:0;

font-family:"Microsoft YaHei UI";

}

/*1.顶部样式*/

.header{

width:100%;

height:80px;

background-color:#07cbc9;

}

.header img{

width:300px;

height:60px;

padding-left:100px;

padding-top:10px;

}

.header .logo{

float:left;

}

.header .nav{

float:right;

}

.header .nav ul{

padding-right:100px;

}

.header .nav ul li{

list-style:none;

float:left;

width:80px;

height:80px;

line-height:80px;

font-size:15px;

font-weight:bolder;

color:#ffffff;

}

.header .nav ul li a{

text-decoration:none;

}

.header .nav ul li a:hover{

color:#fff;

}

/*2.页脚样式*/

.footer{

width:100%;

height:80px;

line-height:80px;

font-size:15px;

background-color:#07cbc9;

color:#ffffff;

text-align:center;

}

/*3.banner样式*/

.banner{

width:100%;

height:600px;

}

.banner img{

width:100%;

height:600px;

}

/*4.遮盖层样式*/

.opacity img{

position:absolute;

top:80px;

left:0;

background-color:#000;

width:100%;

height:600px;

opacity:0.3;

}

/*5.form表单样式*/

.formTable{

width:500px;

height:300px;

position:absolute;

z-index:3;

top:400px;

margin-top:-150px;

right:50%;

margin-right:-250px;

}

.formTable .yourName{

border:2px solid gray;

width:505px;

height:39px;

background:transparent;

margin-bottom:10px;

}

.formTable .yourPhone{

border:2px solid gray;

width:505px;

height:39px;

background:transparent;

margin-bottom:10px;

}

.formTable .yourEmail{

border:2px solid gray;

width:505px;

height:39px;

background:transparent;

margin-bottom:10px;

}

.formTable .yourComt{

border:2px solid gray;

width:505px;

height:115px;

background:transparent;

margin-bottom:10px;

}

/*5.1表单hover*/

.yourName:hover, .yourPhone:hover, .yourEmail:hover, .yourComt:hover{

background-color:#07cbc9;

}

.formTable .yourSub{

border:2px solid gray;

width:123px;

height:39px;

background:transparent;

color:gray;

margin-left:194px;

}

/*5.2submit hover*/

.yourSub:hover{

border:none;

background-color:#07cbc9;

}

/*6.About区域*/

/*6.1AboutTop*/

.aboutTop{

width:100%;

text-align:center;

margin-top:30px;

}

.aboutTop .aboutTopTit{

font-size:30px;

font-weight:bolder;

}

.aboutTop .aboutTopLine{

width:30px;

height:2px;

background-color:#07cbc9;

margin:0 auto;

margin-top:10px;

}

.aboutTop .aboutTopPara{

color:gray;

font-size:20px;

font-weight:lighter;

line-height:25px;

margin-top:10px;

margin-bottom:10px;

}

/*6.2AboutMiddle*/

.aboutMid{

width:1000px;

margin:0 auto;

border:1px solid blue;

}

.aboutMid .aboutMidPic img{

}

 

</style>

</head>

<body>

<!-- 顶部 -->

<div class="header">

<!-- 顶部-logo -->

<div class="logo">

<a href="#"><img src="images/logo.png"/></a>

</div>

<!-- 顶部-nav -->

<div class="nav">

<ul>

<li><a href="#">HOME</a></li>

<li><a href="#">ABOUT</a></li>

<li><a href="#">GALLERY</a></li>

<li><a href="#">FACULTY</a></li>

<li><a href="#">EVENTS</a></li>

<li><a href="#">CONTACT</a></li>

</ul>

</div>

</div>

<!-- banner图 -->

<div class="banner">

<img src="images/banner3.jpg"/>

</div>

<!-- 遮罩层 -->

<div class="opacity">

<img src="images/opacity.png"/>

</div>

<!-- 遮罩层表单 -->

<form class="formTable">

<!-- yourName -->

<input type="text" class="yourName" placeholder="your Name">

<br/>

<!-- yourPhone -->

<input type="text" class="yourPhone" placeholder="your Phone">

<br/>

<!-- yourEmail -->

<input type="text" class="yourEmail" placeholder="your Email">

<br/>

<!-- comment -->

<textarea class="yourComt" placeholder="Write Your Comment Here"></textarea>

<br/>

<!-- button -->

<input type="submit" class="yourSub" value="SEND MESSAGE">

</form>


<!-- about区 -->

<!-- aboutTop -->

<div class="aboutTop">

<div class="aboutTopTit">ABOUT</div>

<div class="aboutTopLine"></div>

<div class="aboutTopPara">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.</div>

</div>

<!-- aboutMiddle -->

<div class="aboutMid">

<!-- 左边区域 -->

<div class="aboutMidLeft">

<div class="aboutMidLeftTit">&nbsp;A WORD<br/>ABOUT US</div>

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

<button>EXPLORE</button>

</div>

<!-- 中间图片 -->

<div class="aboutMidPic">

<img src="images/bb3.jpg"/>

</div>

<!-- 右边区域 -->

<div class="aboutMidRight"></div>

</div>




<!-- gallery区 -->

<div>11</div>

<!-- 页脚区 -->

<div class="footer">

@ 2016 imooc.com 京ICP备13046642号

</div>

</body>

</html>


about中部区域图片始终无法居中,想请问老师问题在哪里?

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕夭夭 2020-05-06 11:11:40

同学你好,老师这边用你的代码测试,图片并没有设置任何样式。没有设置居中,怎么会居中呢。如下:

http://img1.sycdn.imooc.com//climg/5eb229930917956e16930479.jpg

例如给父元素设置如下,图片就能居中

http://img1.sycdn.imooc.com//climg/5eb22a0b0929674217430576.jpg

不过这里的布局并不需要给图片设置居中,about中间区域的三个盒子设置浮动显示在一行,并设置固定宽度,这样中间的盒子自然在中间显示。示例:

http://img1.sycdn.imooc.com//climg/5eb22add09e57dd006290353.jpg

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师