2010-02-07 30 views
0

我无法设置内联元素背景是这样的:内嵌元素有2条以上线(一个在另一个内)

alt text

我的代码是这样的:

#divMansetKategoriHaberleriContainer 
{ 
    background-color: Transparent; 
    margin-top: 4px; 
    font-size: 12px; 
} 
.divKategoriHaberItem 
{ 
    float: left; 
    background-color: White; 
    width: 324px; 
    height: 126px; 
    margin: 0; 
    padding: 0; 
} 
.divKategoriHaberItemImage 
{ 
    float: left; 
    width: 80px; 
    height: 80px; 
    border: 1px solid red; 
    margin: 2px; 
} 
.imgKategoriHaberResim_Cevre 
{ 
    width: 95%; 
    height: 95%; 
} 
.divKategoriHaberItemBaslikIcerik 
{ 
} 
.spHaberBaslik_Cevre 
{ 
    background-color: Green; 
    display: inline; 
    font-weight: bold; 
    padding: 5px; 
    height: 20px; 
} 

.spHaberIcerik_Cevre 
{ 
    display: block; 
} 
.divKategoriHaberDevami_Cevre 
{ 
    background-image: url('../images/HaberinDevami_Cevre.png'); 
    background-repeat: no-repeat; 
    background-position: right; 
    height: 13px; 
} 




<div class="divKategoriHaberItem"> 
    <div class="divKategoriHaberItemImage"> 
     <img src='' alt='DÜNYANIN MEKANİK Dengesi Bozuldu' class="imgKategoriHaberResim_Cevre" /> 
    </div> 
    <div class="divKategoriHaberItemBaslikIcerik"> 
     <span class="spHaberBaslik_Cevre"> 
      <a href='CevreHaber.aspx?id=2128'>DÜNYANIN MEKANİK Dengesi Bozul</a> 
     </span> 
     <span class="spHaberIcerik_Cevre">Demokratik Kongo Cumhuriyeti'n</span> 
    </div> 
    <div class="divKategoriHaberDevami_Cevre"></div> 
</div> 

PS :对不起,我写不出句子:(

+1

我没有看到在CSS的一个问题。所以问题可能出现在HTML或其他CSS规则中。请从'<!doctype html>'显示相关代码片段,最好是SSCCE(http://sscce.org)的风格,直到用'' – BalusC 2010-02-07 02:18:28

+0

第一行有一个文本。但它是一条线。我只是想让它的背景色变成绿色。我设置了“padding:5px;”因为我想让它的开始和结束空间更长(左,右,上,下空格)。但正如你所看到的那样,包装线看起来像是另一个。 – uzay95 2010-02-07 02:35:11

+0

我现在看到了(在我摘下眼镜后,在离屏幕约10厘米处的屏幕截图中,研究了截图中极为复杂的flashblue + darkgreen)。那么,加比的答案是对的。你需要设置'line-height'。 – BalusC 2010-02-07 03:09:42

回答

2

如果我理解正确的问题,您将需要添加一个行高度等于您的内联元素的总高度的...

你的情况,这将是30像素(20像素的高度+ 10px的用于填充5px的顶部和底部为5px ..)

.spHaberBaslik_Cevre 
{ 
    background-color: Green; 
    display: inline; 
    font-weight: bold; 
    padding: 5px; 
    height: 20px; 
    line-height:30px; /*height + padding-top +padding-bottom*/ 
} 
相关问题