2017-08-30 3 views
0

ブロックの基本的なグリッドがあります。また、1つのデザインでは、テキストを下部に配置したいと思っています。私が抱えている問題は、100%のような高さの全幅を使用するこの種のブロック上にクラスを設定することです。それは現在ブロックのCSSテキストの配置をブロックします。

私はこの

<div class="element-container ant-col-xs-24 ant-col-sm-12 ant-col-md-6" style="position: absolute; left: 614px; top: 300px;"> 

    <div class="element-wrapper"> 
     <div class="contents-wrapper"> 
      <div class="title">We are always here to help</div> 
      <div class="contents"> 
       <div> 
        <p class="white-text absolute-bottom">When to seek support call 0202 000 000</p> 
       </div> 
      </div> 
     </div> 
     <div class="contents-background"> 
      <img class="small" src="http://www.dustydavis.com/wp-content/uploads/2017/05/Home-Buying-1.jpg"></div> 
     </div> 
    </div> 

</div> 
のようなルックスアップマーク

enter image description here

のように見えることを確認しようとしています何

enter image description here

//どのように見えるか

//

scss

.elements { 

    .element-container{ 
     width: 200px; 

     .element-wrapper{ 
      background: #ffffff; 
      border: 1px solid black; 
      height: 280px; 

      margin:10px; 

      .contents-wrapper{ 
       position: relative; 
       z-index: 1; 

       .title{ 
        padding:10px; 
        background: #676766; 
        color: #ffffff; 
       } 
       .contents{ 
        padding:10px; 
       } 
      } 

      .contents-background{ 
       margin:10px; 
       position: absolute; 
       left: 1px; 
       bottom: 1px; 
       right: 1px; 
       top: 1px; 
       overflow: hidden; 
       z-index: 0; 

       img{ 


       & 

       &.small{ 
        width: auto; 
        height: 100%;     
       } 

       } 
      } 

     } 

    } 
} 

私はあなたが.contentsを配置しようとしたことがあり、ベースjsfiddle

http://jsfiddle.net/0ht35rpb/111/

.demowrap{ 
 
\t width: 600px; 
 
\t height: 600px; 
 
    position: relative; 
 
\t border:1px solid red; 
 
} 
 
.elements { 
 

 
} 
 

 

 
.element-container{ 
 
width: 280px;/*demo width*/ 
 

 

 
} 
 

 
.element-wrapper{ 
 
background: #ffffff; 
 
border: 1px solid black; 
 
height: 280px; 
 

 
margin:10px; 
 

 
} 
 

 
.contents-wrapper{ 
 
\t position: relative; 
 
\t z-index: 1; 
 
} 
 

 
.contents-wrapper .title{ 
 
\t padding:10px; 
 
\t background: #676766; 
 
\t color: #ffffff; 
 
} 
 

 

 
.contents-wrapper .contents{ 
 
\t padding:10px; 
 
} 
 

 
.contents-background{ 
 
    margin:10px; 
 
    position: absolute; 
 
    left: 1px; 
 
    bottom: 1px; 
 
    right: 1px; 
 
    top: 1px; 
 
    overflow: hidden; 
 
    z-index: 0; 
 
} 
 

 
.contents-background img.large{ 
 
\t width: 100%; 
 
\t height: auto; \t \t  \t \t 
 
} 
 

 
.contents-background img.small{ 
 
\t width: auto; 
 
\t height: 100%; \t \t  \t \t 
 
} 
 

 
<div class="demowrap"> 
 

 
<div class="element-container ant-col-xs-24 ant-col-sm-12 ant-col-md-6" style="position: absolute; left: 0px; top: 0px;"> 
 

 
<div class="element-wrapper"> 
 
\t <div class="contents-wrapper"> 
 
\t \t <div class="title">We are always here to help</div> 
 
\t \t <div class="contents"> 
 
\t \t \t <div> 
 
\t \t \t \t <p class="white-text absolute-bottom">When to seek support call 0202 000 000</p> 
 
\t \t \t </div> 
 
\t \t </div> 
 
\t </div> 
 
\t <div class="contents-background"> 
 
\t \t <img class="small" src="http://www.dustydavis.com/wp-content/uploads/2017/05/Home-Buying-1.jpg"></div> 
 
\t </div> 
 
</div> 
 

 

 
<div class="element-container ant-col-xs-24 ant-col-sm-12 ant-col-md-6" style="position: absolute; left: 300px; top: 0px;"> 
 

 
<div class="element-wrapper"> 
 
\t <div class="contents-wrapper"> 
 
\t \t <div class="title">Unaffected sister block</div> 
 
\t \t <div class="contents"> 
 
\t \t \t <div> 
 
\t \t \t \t <p>Another demo block that just stays unaffected</p> 
 
\t \t \t </div> 
 
\t \t </div> 
 
\t </div> 
 
</div> 
 

 
</div> 
 

 

 

 
</div>

+0

申し訳ありませんが失われる可能性があり、私はあなたが達成しようとしている正確に何をするとして少し混乱しています。あなたのフィドルはあなたが現在持っているものと一致しません、そしてピンクの要素への言及はありません。テキストを画像の下部に揃えようとしていますか? –

+0

- はい - テキストを一番下に揃えようとしていますが、このCSSは他のブロック間で共有されています。 jsfiddleはscssを取っていませんか? - ピンクのデザインは実際のデザインの参考になりますが、私の心配はマークアップのトグル/クラスを追加することでこの影響を完全に受けます。 –

+0

@ObsidianAge - 私のデモを更新しました。テキストを下にスナップして配置する - もう一方は同じままです。 –

答えて

1

を持っていますか? .content-wrapperが100%の高さの場合は、.contentsを下部に揃えることができます。

.contents-wrapper { 
    height: 100%; // add 
} 
.contents { 
    position: absolute; // add 
    bottom: 0; // add 
} 

また、余分なdiv

+0

- 他の共有された側面にも影響を与えますそれは200%のような固定値が与えられていれば確実です - これは健全な論理です –

+0

@TheOldCounty親要素 '.element-wrapper'は固定高さです。あなたのコンテンツラッパーに100%の高さを設定するとは思わないでしょう。 – nGAGE

+0

確かに - 子供の要素の中に再び高さを固定する - それを回避する方法はありますか? –

関連する問題