2017-06-07 14 views
0

このテーブルセル内のテキストを水平に整列するにはどうすればよいですか?それは右に浮いているように見えますが、私はなぜそれがわかりません。 https://jsfiddle.net/o06e11o9/テーブル内のテーブルセルを水平に整列する

HTML

<div class="affil2"> 
    <div class="oval2"></div> 
    <div class="contents"> 
    a lorem ipsum dolor sit amet. Donec facilisis tortor ut augue lacinia, at viverra est semper. Sed sapien metus, tempor a tortor. 
    <br /> 
    <br /> Pellentesque non dignissim neque. Ut porta viverra est, ut dignissim elit elementum ut. 
    </div> 
</div> 

CSS

.affil2 { 
    align-content: center; 
    display: table; 
    text-align: center; 
    z-index: 20; 
    border: 1px solid #705A1D; 
    position: relative; 
    height: 200px; 
    width: 960px; 
    background-color: #af9254; 
    box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, .35); 
} 

.contents { 
    margin: 0 auto; 
    text-align: left; 
    width: 600px; 
    display: table-cell; 
    vertical-align: middle; 
    color: #fff; 
    font-size: 18px; 
} 

.oval2 { 
    z-index: 1; 
    position: absolute; 
    top: -110px; 
    width: 1200px; 
    height: 250px; 
    border-radius: 100%; 
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.3) 0%, rgba(255, 0, 0, 0) 100%); 
} 

答えて

0

あり、あなたのコード内の多くの奇妙なことがありますが、あなたのソリューションのためにあなたを変更することができます。

width: 100%;とクラスcontents

.contents { 
    margin: 0 auto; 
    text-align: center; 
    width: 100%; 
    display: table-cell; 
    vertical-align: middle; 
    color: #fff; 
    font-size: 18px; 
} 

JsFiddle Link

+0

の私は、ソリューションの束をしようとしていた "奇妙なもの" のうちのいくつかの結果である可能性がありますが、ただ、ほとんどI私が何をしているのか分からない。 – HFHaunter

+0

私は段落の形で私のテキストを保ちたい、それはなぜ私は600pxの幅でそれを持っていた。これを行うには、コンテンツ内に子divを作成する必要がありますか?その中にテキストを配置しますか? – HFHaunter

+0

ああ。左右に均等にパディングすることで固定しました。お手伝いありがとう! – HFHaunter

0

CSS

.contents { 
    padding-left: 200px;//hfhaunter 
    padding-right: 200px;//hfhaunter 
    margin: 0 auto; 
    text-align: center; 
    width: 100%;//thank you pablo cesar cordova morales 
    display: table-cell; 
    vertical-align: middle; 
    color: #fff; 
    font-size: 18px; 
} 
関連する問題