我有一個滑塊,被封裝在一個div中。每個元素都放在這個div中,並且圖像被設置爲div的背景。左側有一張圖片,右側有一張標題和文字,以及一個號召性用語按鈕。防止圖像和文字重疊
我希望圖像立即留在文本左側。如果我將文本的寬度設置爲更小,則在移動設備上查看頁面時,圖像將使文本無法讀取。你認爲HTML & .css中的哪些實現是實現這個工作的最好/最簡單的方法?
.slide-email-thread {
background: url("http://4.imimg.com/data4/YP/FD/MY-13642581/hp-laptop-500x500.jpg") no-repeat bottom left;
background-size: contain;
height: 500px;
width: 120%;
bottom: 8px;
left: 16px;
}
.email-thread-header{
font-family: Arial,Helvetica,sans-serif;
padding-top: 20px;
padding-bottom: 20px;
font-size: 40px;
width: 95%;
margin: 0;
color: #FFFFFF;
font-weight: bold;
text-transform: uppercase;
}
.email-thread-text {
color:#FFFFFF;
font-size: 15px;
margin: 0 auto 30px;
width: 100%;
}
.email-thread-btn-link {
width: 50%;
}
.email-thread-button {
}
.email-thread-btn {
border: 2px solid #FFFFFF !important;
border-radius: 3px;
background-color: transparent !important;
text-decoration: none;
transition: background-color 0.5s ease, color 0.5s ease, border 0.5s ease;
font-size: 1.2em;
color: #FFFFFF !important;
padding: 1% 1%;
display: inline-block;
margin: 0 auto;
width: 30%;
}
.email-thread-btn:hover{
text-decoration: none;
color:#F8981D !important;
transition: background-color 0.5s ease, color 0.5s ease, border 0.5s ease;
background-color: #FFFFFF !important;
}
.slide-content {
margin:0px auto;
width:100%;
line-height:1.1
margin-top: -30px;
font-weight:400;
margin-bottom:30px;
width:75%;
text-align:left;
padding:20px;
}
<div class="gradient-bg-email-thread slide">
<div class="slide-email-thread">
<div class="slide-content">
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQhhrwa3eP_qIPbSl9jCJe1JrAN7ahuI0IozBVF89fLJH0X7izl" style="padding-top: 20px;"/>
<div class="email-thread-header">Introducing My Site</div>
<div class="email-thread-text">My text is here & it is overlappng.</div>
<div class="email-thread-link"><a class="home_slide-banner email-thread-btn" href="example.com" target="_blank">CHECK IT OUT</a></div>
</div>
</div>
</div>
滑塊必須是一個div,它會更好的圖像簡單地把DIV中,而不是使它在div滑塊內的背景是什麼?
爲了在移動設備上顯示好,最好是將圖像的不透明度添加到文本可以讀取?不確定更容易做的事情在這裏。
JS小提琴這裏舉例:https://jsfiddle.net/b63xwb0z/
你能提供一個工作演示嗎? –
你可以發佈一個jsfiddle或其他東西,使這更容易閱讀? –
我使用你的代碼創建了一個jsFiddle(只是改變了圖像以使其可以工作),但也許缺少CSS,行爲不是有意的,它不會那樣(我的意思是,你聲明的錯誤不是沒有適當的行爲)。 https://jsfiddle.net/tjvL10f7/ –