我是一名初学者,想要在学习过程中可视化我所做的html和css更改,因此我想在添加的所有元素周围加上边框。
问题:当overflow设置为hidden时,html/body元素周围的蓝色边框被裁剪,在底部和右侧边框不完全显示。
为什么即使将其宽度和高度设置为100%,边框也会超出html页面?
HTML
问题:当overflow设置为hidden时,html/body元素周围的蓝色边框被裁剪,在底部和右侧边框不完全显示。
为什么即使将其宽度和高度设置为100%,边框也会超出html页面?
HTML
<!DOCTYPE html>
<html>
<head>
<title> Practice Webpage </title>
<link href="stylesrevised.css" rel="stylesheet" type="text/css" >
</head>
<body></body>
</html>
CSS
html,body{
width: 100%;
height: 100%;
margin: 0; /* Space from this element (entire page) and others*/
padding: 0; /*space from content and border*/
border: solid blue;
border-width: thin;
overflow:hidden;
display:block;
}
outline: 1px solid blue;
而不是border
。边框不仅会影响盒模型,正如下面的答案所说,还可能会防止边距折叠。 - Web_Designerbody
或者html
上使用outline
属性会导致其在可视窗口外无法显示。如果想要看到它,您需要使用outline-offset: -1px
属性来进行设置。请务必将偏移量设置为轮廓线宽度的负数(例如:outline: 17px solid blue; outline-offset: -17px
)。 - pbarney