2009-08-22 48 views
3

我有這個在我的CSS:如何使用CSS從無序列表中刪除項目符號?

.MainMenu 
{ 
    position: absolute; 
    top:105px; 
    left:15px;  
    background-color: #67E300; 
    color:White; 
    border-style:double; 
    border-color:White; 
    list-style-type:none; 
} 

而這個母版的內部:

<div class="MainMenu"> 
     <uc2:MainMenu ID="MainMenu1" runat="server" /> 
    </div> 

最後這段代碼在用戶控件的MainMenu內:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MainMenu.ascx.cs" Inherits="LoCompro.UserControls.MainMenu" %> 
<ul> 
    <li>Inico</li> 
    <li>Navegar Por Categoria</li> 
    <li>Navegar Por Marca</li> 
    <li>Buscar</li> 
</ul> 

編輯(忘了問這個問題,哈哈):

使用該代碼不刪除項目符號列表。我不想要任何子彈,因爲我想模擬一個菜單。

謝謝你們。 :d

回答

3

嘗試將list-style-type放置在UL上,而不是包含UL的DIV

.MainMenu 
{ 
    position: absolute; 
    top:105px; 
    left:15px;  
    background-color: #67E300; 
    color:White; 
    border-style:double; 
    border-color:White; 
} 


.MainMenu ul 
{ 
    list-style-type:none; 
} 
+0

你的功夫很強。 :3 – 2009-08-22 19:20:05

+0

是不是代碼福? – 2009-08-22 19:28:03

2

是不是隻是

list-style:none; 

而不是

list-style-type:none; 

在貴麗/ OL/UL部分

例如

ol.foo>li { 
    list-style:none; 
} 

.classThatTheListElementIsAMemberOf { 
    list-style:none; 
} 
+0

或'list-style-type',我相信它們是同義詞/別名,但是。上投了反對票。 – 2009-08-22 19:07:05

+0

所以你要說的是在UserControl中使用那個樣式屬性,我實際上聲明瞭無序列表等。 有沒有一種方法可以讓我使用我的CSS。我不喜歡混合造型和內容。謝謝! :·) – 2009-08-22 19:09:13

+3

它們並不完全是別名。列表樣式可讓您將所有列表樣式規則設置爲一個規則(請考慮字體與字體系列)。 – 2009-08-22 19:10:04

0

你所申請的list-style-typediv,不給divul。試試這個:

.MainMenu 
{ 
    position: absolute; 
    top:105px; 
    left:15px;  
    background-color: #67E300; 
    color:White; 
    border-style:double; 
    border-color:White; 
} 

.MainMenu ul 
{ 
    list-style-type:none; 
} 

這將適用於list-style-type任何ul項目內部與上定義的CSS類MainMenu

0

所有你需要的是這在你的CSS:

.MainMenu ul { list-style-type: none; } 

這將.MainMenu DIV,這是你上面貼的代碼的最終結果中匹配UL。

相關問題