2016-03-08 49 views
0

我在這裏遇到了最困難的時間......我已經搜索了一段時間,無法完全弄清楚如何正確地讓我的文本在我的父容器中正確重新調整大小。容器中的響應文本大小問題

下面是代碼:

html, 
 
body, 
 
box, 
 
thumbnail_image, 
 
overlay, 
 
h1, 
 
h3, 
 
h6, 
 
p, 
 
body { 
 
    width: 100%; 
 
    padding-bottom: 25px; 
 
    font-size: 100%; 
 
} 
 

 
input { 
 
    font-family: "Roboto"; 
 
    position: absolute; 
 
    top; 
 
    25.5px; 
 
    font-weight: 700; 
 
    font-size: 14px; 
 
    color: #fff; 
 
    background-color: transparent; 
 
    text-align: right; 
 
    border-width: 0; 
 
    width: 100%; 
 
    margin: 0 0 .1em 0; 
 
} 
 

 
.heart_button { 
 
    position: absolute; 
 
    top: 25.5px; 
 
    right: 55px; 
 
} 
 

 
.heart_button:hover, 
 
.heart_button:active, 
 
.heart_button:focus { 
 
    color: #dd0239; 
 
} 
 

 
.heart_background { 
 
    position: absolute; 
 
    top: 20px; 
 
    right: 20px; 
 
    background-color: #000000; 
 
    opacity: .1; 
 
    width: 65px; 
 
    height: 30px; 
 
    border-radius: 15px; 
 
} 
 

 
.box { 
 
    margin: 50px auto; 
 
    position: relative; 
 
    max-width: 90%; 
 
    height: 490px; 
 
    width: 700px; 
 
    background-color: #18a0ff; 
 
    box-shadow: 1px 15px 50px 2px; 
 
} 
 

 
.quote_image { 
 
    position: absolute; 
 
    opacity: .1; 
 
    top: 62px; 
 
    left: 51px; 
 
} 
 

 
.image_overlay { 
 
    background-color: #282a37; 
 
    width: 170px; 
 
    height: 490px; 
 
    position: absolute; 
 
    float: left; 
 
} 
 

 
.thumbnail_image { 
 
    position: absolute; 
 
    float: left; 
 
    opacity: .12; 
 
    display: inline-block; 
 
} 
 

 
.text_container { 
 
    left: 200px; 
 
    width: 400px; 
 
    height: 338px; 
 
    max-width: 90%; 
 
    word-wrap: break-word; 
 
    position: absolute; 
 
} 
 

 
h1 { 
 
    color: #fff; 
 
    text-transform: uppercase; 
 
    font-size: 3.7em; 
 
    font-family: Montserrat; 
 
    font-weight: 700; 
 
    line-height: 1.3; 
 
    text-align: left; 
 
    width: 100%; 
 
    word-wrap: break-word; 
 
    
 
} 
 

 
.author_name { 
 
    position: absolute; 
 
    left: 206px; 
 
    bottom: 0px; 
 
} 
 

 
h3 { 
 
    font-family: Open Sans; 
 
    font-weight: 700; 
 
    letter-spacing: 1px; 
 
    text-transform: uppercase; 
 
    font-size: 1em; 
 
    text-align: left; 
 
    color: #fff; 
 
} 
 

 
p { 
 
    font-family: "Roboto"; 
 
    font-weight: 700; 
 
    font-size: 14px; 
 
    color: #fff; 
 
    text-align: center; 
 
} 
 

 
h6 { 
 
    font-family: Open Sans; 
 
    font-weight: light; 
 
    font-size: 1em; 
 
    letter-spacing: 2px; 
 
    text-transform: uppercase; 
 
    text-align: center; 
 
} 
 

 
nav { 
 
    position: absolute; 
 
    left: 35px; 
 
    bottom: 28px; 
 
} 
 

 
html { 
 
    background: linear-gradient(209deg, #E5ECEF 40%, #BBC2C5 100%) no-repeat center center fixed; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
} 
 

 
#footer { 
 
    clear: both; 
 
} 
 

 
@media screen and (max-width: 649px) { 
 

 
    .box { 
 
    width: 450px; 
 
    height: 350px; 
 
    max-width: 90%; 
 
    } 
 
    
 
    h1 { 
 
    font-size: 2em; 
 
    word-wrap: break-word; 
 
    } 
 
    
 
    .text_container { 
 
    width: 280px; 
 
    height: 236.6px; 
 
    max-width: 90%; 
 
    } 
 
}
<body> 
 
    <div class="box"> 
 
    <div class="heart_button"> 
 
     <img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457311522/little_heart_jle1j3.png"> 
 
    </div> 
 
    <div class="heart_background"> 
 
    </div> 
 
    <div class="image_overlay"> 
 
    </div> 
 
    <div class="thumbnail_image"> 
 
     <img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457298445/Sheldon_Pic_l3cprk.jpg"> 
 
    </div> 
 
    <div class="text_container"> 
 
     <h1>Don't You think that if I were wrong, &nbsp;&nbsp; &nbsp; I'd know it?</h1> 
 
    </div> 
 
    <div class="author_name"> 
 
     <h3> - Sheldon Cooper </h3> 
 
    </div> 
 
    <div class="quote_image"> 
 
     <img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457314397/quotations_image_wfwimc.png"> 
 
    </div> 
 
    <nav> 
 
     <img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457364436/arrow-left_moebxn.png"> 
 
     <img src="http://res.cloudinary.com/dp32vpqfu/image/upload/v1457364436/arrow-right_oilpij.png"> 
 
    </nav> 
 
    </div> 
 
</body>

如此反覆,我的想法是,我可以有.box的類是父容器,然後將被嵌套在.text_container可能'在較小的視口中以適應性的方式重新調整文本的大小。但它不是......而我的頭髮變灰了。

Errggghhhh ...

回答

0

孩子絕對位置不能改變大小或其父母或反之亦然。或者,您可以使用float屬性並將其設置爲「正確」。此外,如果您要瞄準響應式設計,則可能需要使用%而不是像素。

+0

你的意思%在H1類文本或者在容器類中設置字體大小? –

+0

http://codepen.io/fitri/pen/oxbQJE檢查這個選擇。最好在媒體查詢中使用最小寬度(移動優先方法)。 – Fitri