为什么合起来3个id标签定义,宽度不能100%占满?_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:04:52
Original
1338 people have browsed it

<!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 type="text/css">	div{		border:1px solid #039;		text-align:center;			}	#header{		width:100%;		height:80px;	}	.logo{		width:30%;		background-color:#0fc;		float:left;	}	.today{		width:30%;		background-color:#ccc;		float:left;	}	.search{		width:39.5%;/*定义为40%会导致搜索栏不能和前两个在同一行。*/		background-color:#cf9;		float:left;	}	</style></head><body>	<div id="header">    	<div class="logo">网站Logo</div>        <div class="today">当前日期</div>        <div class="search">搜索栏</div>    </div></body></html>
Copy after login


回复讨论(解决方案)

你把所有div样式
div{
        border:1px solid #039;
        text-align:center;       
    }
加了边框,肯定不能按照100%来设置,你把边框去掉就可以了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!