CSSの

2016-04-08 5 views
0

を使用して、div内のスパンの背景をフルサイズにする私たちのゲームサーバーのコントロールパネル用のゲームサーバーコンソールを作成しようとしています。 私が持っている小さなスタイリングの問題は、すべての奇数ラインが少し明るい背景を持つ必要があるということです。CSSの

の代わりにこの: enter image description here

コード:

showLoading('gameTerminal_content', '32', 'html', '');
.gameTerminal_content_outputLine:nth-of-type(odd) { width:500px; background: #4C3C33; }
<div class="well-md" id="gameTerminal" style="background: #2A211C; height: 300px; max-width: 100%; overflow-y:scroll; font-family:'Courier New', Courier, monospace"> 
 
    \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
    <p> 
 
    \t \t \t \t \t \t \t \t \t \t \t 
 
    <span id="gameTerminal_content" style="color:#80FF80; width: 100%;"> 
 
    
 
    <span class="gameTerminal_content_outputLine">Line 1</span><br /><br /> 
 
    <span class="gameTerminal_content_outputLine">Line 2</span><br /><br /> 
 
    <span class="gameTerminal_content_outputLine">Line 3</span><br /><br /> 
 
    \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
    </span> 
 
    
 
    </p> 
 
    \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
    <!--<input type="text" name="gameTerminal_input" style="background: #4C3C33; float: left; color: #FFFFFF; width: 90%; border:none; position: absolute; bottom: 0; outline: none;" />--> 
 
    
 
    <div id="gameTerminal_scrollHeigth"></div> 
 
    
 
    </div>

答えて

1

あなたが欲しいですdivの幅を占めるようにするには、スパンをインラインブロックにする必要があります。ただ、追加:

.gameTerminal_content_outputLine { display: inline-block; }

スニペット:

showLoading('gameTerminal_content', '32', 'html', '');
.gameTerminal_content_outputLine:nth-of-type(odd) { width:500px; background: #4C3C33; } 
 
.gameTerminal_content_outputLine { 
 
\t display: inline-block; 
 
}
<div class="well-md" id="gameTerminal" style="background: #2A211C; height: 300px; max-width: 100%; overflow-y:scroll; font-family:'Courier New', Courier, monospace"> 
 
    \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
    <p> 
 
    \t \t \t \t \t \t \t \t \t \t \t 
 
    <span id="gameTerminal_content" style="color:#80FF80; width: 100%;"> 
 
    
 
    <span class="gameTerminal_content_outputLine">Line 1</span><br /><br /> 
 
    <span class="gameTerminal_content_outputLine">Line 2</span><br /><br /> 
 
    <span class="gameTerminal_content_outputLine">Line 3</span><br /><br /> 
 
    \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
    </span> 
 
    
 
    </p> 
 
    \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
    <!--<input type="text" name="gameTerminal_input" style="background: #4C3C33; float: left; color: #FFFFFF; width: 90%; border:none; position: absolute; bottom: 0; outline: none;" />--> 
 
    
 
    <div id="gameTerminal_scrollHeigth"></div> 
 
    
 
    </div>

+0

正確に私が探していた場所、実際に私が欲しかったことを読んでくれてありがとう:) –

1

は、あなただけの偶数ラインをターゲットにしたスタイルを追加できませんでした enter image description here

私はこれが欲しいですを使用して

.gameTerminal_content_outputLine:nth-of-type(odd) { 
    width:500px; 
    background: #4C3C33; 
} 
.gameTerminal_content_outputLine:nth-of-type(even) { 
    width:500px; 
    background: #5D4D44; 
} 

アップデート私はあなたが要素の各列の間の明示的なパディングを取り除くために望んでいたが実現しなかった

:同様の奇数の要素をターゲットにし、あなたの現在の1よりもやや明るくなっ。要素が<span>要素なので、あなたはdisplay:blockにそれらを設定するためにそれらを設定したい:

this exampleで見られるし、以下に示すようなコンテンツをレンダリングするでしょう
.gameTerminal_content_outputLine { 
     display: block; 
} 

enter image description here

+0

これは私が尋ねたものではありません:私は既に今、奇妙な色を与える方法を教えてください。私が投稿したジャヤリンクを見てください。違いを見てください。 –

+0

'display:block'プロパティを設定しましたか?この変更を反映するように私の回答を更新しました(あなたが探していたものにもっと適しています)。 –

+0

はい、ありがとうございます。これも動作します:) –

1

あなたはthisを望んでいますか? (あなたの写真による)

.gameTerminal_content_outputLine { display: block; width: 100%; }