div 居中_html/css_WEB-ITnose

WBOY
发布: 2016-06-24 12:06:10
原创
996 人浏览过

<html><head></head><body>	<div align=center>		<div style="width:1100px;height:40px;border:2px solid red;">11111111111111111111</div>		<div style="float:left;width:200px;height:40px;border:2px solid red;">222</div>		<div style="float:left;width:200px;height:40px;border:2px solid red;">333</div>		<div style="float:left;width:700px;height:40px;border:2px solid red;">444</div>	</div></body></html>
登录后复制


只有第一个div 居中了,下面三个还是居左

怎么让他们都居中


回复讨论(解决方案)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style>.cf:after{content:'';display:block;clear:both;}.cf{zoom:1;}.f{margin:0 auto; width:1112px;}</style></head><body> <div class="box">        <div style="width:1100px;height:40px;border:2px solid red;margin:0 auto;">11111111111111111111</div>        <div class="f cf">            <div style="float:left;width:200px;height:40px;border:2px solid red;">222</div>            <div style="float:left;width:200px;height:40px;border:2px solid red;">333</div>            <div style="float:left;width:700px;height:40px;border:2px solid red;">444</div>        </div>    </div></body></html>
登录后复制

因为你下面三个div都使用了float处理。


11111111111111111111

222

333

444

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!