gpt4 book ai didi

html - 填充 2px 顶部和底部有什么意义

转载 作者:太空宇宙 更新时间:2023-11-04 15:12:58 25 4
gpt4 key购买 nike

在声明“#message a”中,我有一个看起来像这样的样式填充

padding: 2px 15px; 

那么当外观没有变化时,填充顶部和底部有什么意义。即使我将填充更改为

"padding: 100px 15px;" 

这100px在外观上没有任何变化。这个 15px 是正确的,并且在外观上做了一些改变。

<!DOCTYPE>
<html>
<head>
<title>Chapter 3: Expandable Rows</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
body
{
margin:5px;
padding: 0;
font-family: Arial, sans-serif;
font-size: small;
text-align: center;
width: 768px;
}

#register
{
float: left;
width: 100%;
margin:0;
padding: 0;
list-style: none;
color: #690;
background: #BDDB62;
}

#register a
{
text-decoration: none;
color: #360;
}

#reg
{
float: left;
margin: 0;
padding: 8px 14px;
}

#find
{
float: right;
margin: 0;
padding: 8px 14px;
}

#message
{
clear:both;
font-weight: bold;
font-size:110%;
color:#fff;
text-align: center;
background: #92B91C;
}


#message p
{
margin: 0;
padding: 8px 14px;
}

#message strong
{
text-transform: uppercase;
}

#message a
{
margin: 0 0 0 6px;
padding: 2px 15px;
text-decoration: none;
font-weight: normal;
color: #fff;
}

</style>
</head>

<body>

<ul id="register">
<li id="reg">Not registered? <a href="#">Register</a> now!</li>
<li id="find"><a href="#">Find a store</a></li>
</ul>

<div id="message">
<p><strong>Special this week:</strong> $2 shipping on all orders! <a
href="#">LEARN MORE</a></p>
</div>`enter code here`
</body>
</html>

最佳答案

anchor 标记是内联元素,因此不会显示垂直填充。

While padding can be applied to all sides of an inline element, only left and right padding will have an effect on surrounding content.

要查看应用的垂直填充,请将 a 更改为 display:inline-block

#message a{
padding: 2px 15px;
display: inline-block;
}

示例 http://jsfiddle.net/sL7kT/

See this article on how CSS properties are applied to inline elements .

关于html - 填充 2px 顶部和底部有什么意义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18122951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com