html5 - html,为什么右边框会被挡住?
PHP中文网
PHP中文网 2017-04-17 13:15:30
[HTML讨论组]

我用这样的样式描绘,为什么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>

'''

PHP中文网
PHP中文网

认证0级讲师

全部回复(2)
PHP中文网

下面有个滚动条嘛,你拉到右边去就看到啦。
你的宽度设置太大把整个页面都撑宽了。
给你的container加个box-sizing:border-box;

PHP中文网

html每个标签都会有外边距和内边距的

你把p设置成100%而没有把边距消去掉的话
页面宽度 = 窗口宽度 + 2*margin值
显然会溢出窗口

样式里加下面代码

*{
    padding:0px;
    margin:0px;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号