2017-06-12 13 views
0

私がカードのUIを作成しようとしています:https://codepen.io/sarimabbas/pen/qjZYvr隣接のdivにdivのオーバーフローをフェージング

.book_left { 
    width: 35%; 
    height: 300px; 
    float: left; 
    overflow-x: hidden; 
    background: transparent; 
} 
.book_left img { 
    width: auto; 
    height: 100%; 
    border-radius: 10px 0 0 10px; 
    -webkit-border-radius: 10px 0 0 10px; 
    -moz-border-radius: 10px 0 0 10px; 
    position: relative; 
} 
.book_right { 
    width: 65%; 
    height: 300px; 
    float: left; 
    background: #000000; 
    border-radius: 0 10px 10px 0; 
    -webkit-border-radius: 0 10px 10px 0; 
    -moz-border-radius: 0 10px 10px 0; 
} 

私はに実行して問題が(画像が含まれています)カードの左側は、オーバーフローことができるということです右に。このオーバーフローを隠す代わりに、右のdivにそれをブレンドして、テキストが隠されずに読めるようにしたいと思います。

このようなことは可能でしょうか?私は浮動小数点、背景画像フェードとdivの組み合わせを研究しようとしましたが失敗しました。

関連するノートでは、このようなカードを反応させるために必要な手順は何でしょうか?

答えて

0

私は完全にはわかりませんが、下のコードを使用すると、オーバーフローした画像の上にテキストが表示されるようになります。完全に黒い背景を持つことはオプションではありません。応答性に関しては

.book_right { 
    width: 65%; 
    height: 300px; 
    float: left; 
    background: rgba(0,0,0, 0.5); 
    border-radius: 0 10px 10px 0; 
    -webkit-border-radius: 0 10px 10px 0; 
    -moz-border-radius: 0 10px 10px 0; 
    position: relative; 
} 

、私の代わりに山車と使用率の代わりに、幅と高さのピクセルのフレキシボックスのために行くだろう。

@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700); 
 
@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css); 
 
.book { 
 
    width: 450px; 
 
    height: 300px; 
 
    background: transparent; 
 
    position: static; 
 
    left: 0; 
 
    right: 0; 
 
    margin: auto; 
 
    top: 0; 
 
    bottom: 0; 
 
    border-radius: 10px; 
 
    -webkit-border-radius: 10px; 
 
    -moz-border-radius: 10px; 
 
    box-shadow: 0 2px 1px 0 #777; 
 
} 
 
.book_left { 
 
    width: 35%; 
 
    height: 300px; 
 
    float: left; 
 
    overflow-x: visible; 
 
    background: transparent; 
 
} 
 
.book_left img { 
 
    width: auto; 
 
    height: 100%; 
 
    border-radius: 10px 0 0 10px; 
 
    -webkit-border-radius: 10px 0 0 10px; 
 
    -moz-border-radius: 10px 0 0 10px; 
 
    position: relative; 
 
} 
 
.book_right { 
 
    width: 65%; 
 
    height: 300px; 
 
    float: left; 
 
    background: rgba(0,0,0, 0.5); 
 
    border-radius: 0 10px 10px 0; 
 
    -webkit-border-radius: 0 10px 10px 0; 
 
    -moz-border-radius: 0 10px 10px 0; 
 
    position: relative; 
 
} 
 
.book_right h1 { 
 
    color: white; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-weight: 400; 
 
    text-align: left; 
 
    font-size: 20px; 
 
    margin: 30px 0 0 0; 
 
    padding: 0 0 0 40px; 
 
    letter-spacing: 1px; 
 
} 
 
.book_right_details ul { 
 
    list-style-type: none; 
 
    padding: 0 0 0 40px; 
 
    margin: 10px 0 0 0; 
 
} 
 
.book_right_details ul li { 
 
    display: inline; 
 
    color: #e3e3e3; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-weight: 400; 
 
    font-size: 14px; 
 
    padding: 0 40px 0 0; 
 
} 
 
.book_right_blurb p { 
 
    color: white; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-size: 12px; 
 
    padding: 0 40px 0 40px; 
 
    letter-spacing: 1px; 
 
    margin: 10px 0 10px 0; 
 
    line-height: 20px; 
 
} 
 
.book_right_blurb a { 
 
    text-decoration: none; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-size: 14px; 
 
    padding: 0 0 0 40px; 
 
    color: #2ecc71; 
 
    margin: 0; 
 
} 
 
.book_right_button { 
 
    padding: 0 0 0 40px; 
 
    margin: 15px 0 0 0; 
 
} 
 
.book_right_button a { 
 
    color: #2ecc71; 
 
    text-decoration: none; 
 
    font-family: 'Montserrat', sans-serif; 
 
    border: 2px solid #2ecc71; 
 
    padding: 5px 5px 5px 5px; 
 
    font-size: 12px; 
 
    border-radius: 5px; 
 
    -webkit-transition-property: all; 
 
    transition-property: all; 
 
    -webkit-transition-duration: .5s; 
 
    transition-duration: .5s; 
 
} 
 
.book_right_button a:hover { 
 
    color: #000000; 
 
    background-color: #2ecc71; 
 
    cursor: pointer; 
 
    -webkit-transition-property: all; 
 
    transition-property: all; 
 
    -webkit-transition-duration: .5s; 
 
    transition-duration: .5s; 
 
}
<div class='book'> 
 
     <div class='book_left'> 
 
      <img src='http://images.gr-assets.com/books/1474171184l/136251.jpg'> 
 
     </div> 
 
     <div class='book_right'> 
 
      <h1>Harry Potter and the Deathly Hallows</h1> 
 
      <div class='book_right_details'> 
 
      <ul> 
 
       <li>JK Rowling</li> 
 
       <li>Fiction</li> 
 
      </ul> 
 
      <div class='book_right_blurb'> 
 
       <p>Harry meets his destiny in the final book of Rowling's acclaimed series.</p> 
 
      </div> 
 
      <div class='book_right_button'> 
 
      <a href='https://www.youtube.com/watch?v=ot6C1ZKyiME' target='_blank'>READ BOOK</a> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div>

0

あり、この問題にはいくつかのアプローチがありますが、私は考えることができる最も簡単なのは右側のボックスにグラデーションの背景を適用し、黒に.bookの背景を設定するようなものです。したがって、次のようなもの(もちろん、いくつかの研磨が必要になります)

@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700); 
 
@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css); 
 
.book { 
 
    width: 450px; 
 
    height: 300px; 
 
    margin: auto; 
 
    border-radius: 10px; 
 
    -webkit-border-radius: 10px; 
 
    -moz-border-radius: 10px; 
 
    box-shadow: 0 2px 1px 0 #777; 
 
    background: #000; 
 
} 
 
.book_left { 
 
    width: 35%; 
 
    height: 300px; 
 
    float: left; 
 
    } 
 
.book_left img { 
 
    width: auto; 
 
    height: 100%; 
 
    border-radius: 10px 0 0 10px; 
 
    -webkit-border-radius: 10px 0 0 10px; 
 
    -moz-border-radius: 10px 0 0 10px; 
 
    /* No need for relative or z-indexes if our layers are in order (later in markup = "higher" layer for position: static) */ 
 
} 
 
.book_right { 
 
    width: 65%; 
 
    height: 300px; 
 
    float: left; 
 
    border-radius: 0 10px 10px 0; 
 
    -webkit-border-radius: 0 10px 10px 0; 
 
    -moz-border-radius: 0 10px 10px 0; 
 
    /* Gradient that sits on left of right panel - black background has also been applied to .book so that if the image doesn't fit the width we won't end up with weird chunks of missing background */ 
 
    /* Generated gradient via: http://colorzilla.com/gradient-editor/ then tweaked a little */ 
 
background: -moz-linear-gradient(left, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 10px, rgba(0,0,0,1) 100%); /* FF3.6-15 */ 
 
background: -webkit-linear-gradient(left, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 10px,rgba(0,0,0,1) 100%); /* Chrome10-25,Safari5.1-6 */ 
 
background: linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(0,0,0,1) 10px,rgba(0,0,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ 
 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#000000',GradientType=1); /* IE6-9 */ 
 
} 
 
.book_right h1 { 
 
    color: white; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-weight: 400; 
 
    text-align: left; 
 
    font-size: 20px; 
 
    margin: 30px 0 0 0; 
 
    padding: 0 0 0 40px; 
 
    letter-spacing: 1px; 
 
} 
 
.book_right_details ul { 
 
    list-style-type: none; 
 
    padding: 0 0 0 40px; 
 
    margin: 10px 0 0 0; 
 
} 
 
.book_right_details ul li { 
 
    display: inline; 
 
    color: #e3e3e3; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-weight: 400; 
 
    font-size: 14px; 
 
    padding: 0 40px 0 0; 
 
} 
 
.book_right_blurb p { 
 
    color: white; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-size: 12px; 
 
    padding: 0 40px 0 40px; 
 
    letter-spacing: 1px; 
 
    margin: 10px 0 10px 0; 
 
    line-height: 20px; 
 
} 
 
.book_right_blurb a { 
 
    text-decoration: none; 
 
    font-family: 'Montserrat', sans-serif; 
 
    font-size: 14px; 
 
    padding: 0 0 0 40px; 
 
    color: #2ecc71; 
 
    margin: 0; 
 
} 
 
.book_right_button { 
 
    padding: 0 0 0 40px; 
 
    margin: 15px 0 0 0; 
 
} 
 
.book_right_button a { 
 
    color: #2ecc71; 
 
    text-decoration: none; 
 
    font-family: 'Montserrat', sans-serif; 
 
    border: 2px solid #2ecc71; 
 
    padding: 5px 5px 5px 5px; 
 
    font-size: 12px; 
 
    border-radius: 5px; 
 
    -webkit-transition-property: all; 
 
    transition-property: all; 
 
    -webkit-transition-duration: .5s; 
 
    transition-duration: .5s; 
 
} 
 
.book_right_button a:hover { 
 
    color: #000000; 
 
    background-color: #2ecc71; 
 
    cursor: pointer; 
 
    -webkit-transition-property: all; 
 
    transition-property: all; 
 
    -webkit-transition-duration: .5s; 
 
    transition-duration: .5s; 
 
}
<div class='book'> 
 
     <div class='book_left'> 
 
      <img src='http://images.gr-assets.com/books/1474171184l/136251.jpg'> 
 
     </div> 
 
     <div class='book_right'> 
 
      <h1>Harry Potter and the Deathly Hallows</h1> 
 
      <div class='book_right_details'> 
 
      <ul> 
 
       <li>JK Rowling</li> 
 
       <li>Fiction</li> 
 
      </ul> 
 
      <div class='book_right_blurb'> 
 
       <p>Harry meets his destiny in the final book of Rowling's acclaimed series.</p> 
 
      </div> 
 
      <div class='book_right_button'> 
 
      <a href='https://www.youtube.com/watch?v=ot6C1ZKyiME' target='_blank'>READ BOOK</a> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div>

それが応答あなたが.book上%の幅を設定し、おそらくそれを浮くことができ作ります。 私のアプローチの注意点は、イメージがオーバーフローしない場合、オーバーフローしないものの隣には奇妙に見えるので、イメージがオーバーフローしないようにすることです。また、画像上のパーセンテージ幅を設定することで、これを攻撃する可能性がありますが、大きく異なる割合で画像の慎重で、彼らは常に300ピクセルの高さをカバーしていることを確認する必要があると思います。別の方法としては、.book_leftに背景画像として画像を設定し、それは多くのあなたの人生を作ってあげると、私は通常、オーバーフローをフェージングの必要性を回避するために一貫性のあるプロポーションに画像をトリミングするために、このインスタンスにお勧めしたいbackground-size: cover

を設定することができます長期的にはより簡単です。

より一貫性があるかもしれないフェードへの別のアプローチは、相対位置を.book_leftとし、その中に絶対配置されたdivを配置し、画像の上にレイヤーを置く勾配バックグラウンドとすることで、あなたがそこにフェードをしたい場合.book_left

position: absolute; 
right: 0; 
z-index: 1; 
width: 10px; 
background: -moz-linear-gradient ..... 

以内に追加の容器を満たす画像に合成これは、あなた

をより一貫性のある外観を与える必要があります
関連する問題