簡體   English   中英

當我在其中添加“空格”時,如何確保文本保持在同一行 <li> 元件?

[英]How do I make sure my text stays on same line when I add a 'space' inside <li> element?

我經常發現自己在瀏覽SOF,並且還沒有發布,所以就在這里。 我正在建立一個新網站,並且是CSS的相對入門者。 我正在用基本的導航菜單苦苦掙扎,只是不能完全研究如何解決問題。

這是我的網站 ,如果您在“聯系人”下拉列表下瀏覽,您會發現第一個列表項位於兩行,而我只希望在“下載”下拉列表中看到該列表項。

萬一有人想要代碼

.nav{
width:100%;
background-color: #0066B9;
font-family: verdana;
font-weight: bold;
padding-top: 4px;
padding-bottom: 4px;
max-height: 31px;
}
.nav ul{
top: 0;
width:960px;
margin:0 auto;
list-style: none;
padding-left: 0px;
display: inherit;
}
.nav li{
display: inline;
position: relative;
background-color: #003E64;
padding-top: 4px;
padding-bottom: 4px;
}
.nav ul li a{
color: white;
text-decoration: none;
padding: 10px;
line-height: 21px;
}
.nav ul li a:hover{
background-color: purple;
color: black;
padding-top: 4px;
padding-bottom: 4px;
}
.nav ul li ul{
display: none;
position: absolute;
margin: 0px;
background-color: #003E64;
width: auto;
}
.nav ul > li > ul{
position: absolute;
left: 0;
margin-top: 27px;
display: none;
padding-top: 10px;
overflow: hidden;
}
.nav ul li:hover > ul{
display: block;
padding-left: 6px;
}
.nav ul > li > ul > li{
position: relative;
display: block;
width: auto;
}
.nav ul > li > ul > li a{
padding: 10px;
}

如果我發帖不正確,請提前致歉。 不確定我要縮進4個空格是什么。

嘗試使用white-space CSS屬性:

.nav li {
    ...
    white-space: nowrap;
}

https://developer.mozilla.org/zh-CN/docs/Web/CSS/white-space

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM