我用这样的样式描绘,为什么container块的右边框会被挡住呢?请达人指教,感谢。
‘’‘html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="almanac.css">
<title>Almanac</title>
<style type="text/css">
.container {border:10px solid #000;width:100%; float: left;}
.year {margin-top: 10px;border-top: 1px solid #000;padding: 10px}
.week {float: right;}
.date {padding-top: 10px;border-top: 1px solid #000;font-size: 150px;text-align:center;}
.today {padding-bottom: 10px;text-align: center;font-size:50px}
.example {padding: 10px;border-top: 1px solid #000;text-align: justify;}
.author {float: right; padding: 10px;font-size: 12px}
</style>
</head>
<body>
<p class="container">
<p class="year"> <span>May 12th, 2016</span> <span class="week">Thursday</span></p>
<p class="date">12</p>
<p class="today">oath</p>
<p class="example"> He swore an oath promising to uphold and protect the country's laws and constitution. </p>
<p class="author">WeChat:xxx</p>
</p>
</body>
</html>
'''
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
下面有个滚动条嘛,你拉到右边去就看到啦。
你的宽度设置太大把整个页面都撑宽了。
给你的container加个
box-sizing:border-box;html每个标签都会有外边距和内边距的
你把p设置成100%而没有把边距消去掉的话
页面宽度 = 窗口宽度 + 2*margin值
显然会溢出窗口
样式里加下面代码