gpt4 book ai didi

html - 阻止 li 元素轮廓接触

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

我的一项任务是创建响应式网页。尝试在手机上打开它时遇到了麻烦。我的“li”元素触感和外观都很糟糕。

如何阻止每个 li 元素周围的“框”接触?

HTML -

      <link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css">


<body>
<center>
<div id="Menubar">
<ul>
<li id="active"><a href="Index.html">Home</a>
</li>
<li><a href="Information.html">Services</a>
</li>
<li><a href="Contact_us.html">Contact</a>
</li>
</ul>
</div>
</center>

CSS -

      #Menubar ul {
padding: .05em 0;
margin: 0;
list-style-type: none;
background-color: #3A3734;
color: #FFF;
width: 100%;
font-family: Oswald;
font-size: 32pt;
font-weight: bold;
text-align: center;
border-top:solid #8E7861 4px;
border-bottom:solid #8E7861 4px;
}
#Menubar ul li { display: inline; }
li a {
text-decoration: none;
margin: 0 0 3px 0;
background-color: white;
color: #6AA0CC;
padding: .1em 1em;
border: 2px solid #6AA0CC;
}
li a:hover {
background-color: #6AA0CC;
color: #fff;
border: 2px solid white;
}
.listcenter{
width:250px;
margin:0 auto;
text-align:left;
}

JSFIDDLE

最佳答案

除了您应用的其他样式之外,将以下代码添加到 li a 选择器。

li a {display:inline-block;}

检查更新的 JSFIDDLE

重要的是,对于响应式网页,您还应该使用媒体查询。

关于html - 阻止 li 元素轮廓接触,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36193147/

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