2014-02-12 98 views
0

enter image description here文本溢出從輸入

我有被我試圖阻止文本從右側溢出的問題,我已經嘗試設置填充右,試圖解決這一問題,但仍然沒有運氣。我怎樣才能解決這個問題?

這是我的html,css文件。

的.html

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <title></title> 
     <link rel="stylesheet" href="css/testing.css" type="text/css" /> 
     <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' rel='stylesheet' type='text/css' /> 
     <style type="text/css"> 
      /* Importing Nomralized CSS */ 
      @import url('css/normalize/normalize.css'); 

     </style> 
    </head> 
    <body> 
     <div id="container"> 
      <div class="header"></div> 
      <div class="content-main-top" id="dpb"> 
       <p class="para"> 
        Our new website is currently under<br/> development. It won't take long, please 
       </p> 
       <span id="clr" class="size" style="margin-top: 60px;"><h1 style="margin-top: 4px; margin-bottom: 3px;">sit tight!</h1></span> 
       <p class="para" style="margin-bottom: 10px; color: #808285; margin-top: 30px; font-weight:"> 
        Fill in your email address and we<br/> 
        will let you know when we launch. 
       </p> 
       <input type="email" class="bubble_email"><input type="submit" name="sub" value="Notify me!" class="button"> 
      </div> 
      <div class="chairs" id="dpb"></div> 
      <!-- end of container --> 
     </div> 
     <!-- Begin Footer --> 
     <div id="footer"> 
      <!-- Start Container --> 
      <div id="container"> 
       <!-- Footer Content --> 
       <div class="content-main-bottom"> 
        <p id="clear_footer"> 
         <span style="color: #808285; font-weight: bolder; line-height: 30px; font-size: 17px;">Get in touch</span><br/> 
        <!-- Tweet Pic --> 
        <a href="https://www.twitter.com/TitanHealthcare" target="_blank" class="tweet"></a> 
         <span class="para">Phone: </span><span style="color: #808285; font-weight: bolder">0845 130 8022</span><br/> 
         <a href="mailto:[email protected]">[email protected]</a> 
        </p> 
        <p style="font-weight: lighter; font-size: 13px; color: #939598"> 
         &copy; Titan Healthcare Limited 2014. All rights reserved. 
        </p> 
       </div> 
       <!-- End of content for footer --> 
      </div> 
      <!-- End of Container --> 
     </div> 
     <!-- End of footer --> 
    </body> 
</html> 

body { 
    font-family: 'Open Sans', sans-serif; 
} 

.para { 
    color: #7c7b7b; 
    font-size: 15px; 
    margin-bottom: 0px; 
    margin-top: 6px; 
} 

.para_b { 
    color: #808285; 
} 
/*Misc ID'S */ 
#clr { 
    color: #34a4b5; 
} 

/*Size class*/ 
.size { 
    font-size: 43px; 

} 

.button { 
    background-color:transparent; 
    outline: none; 
    border: 0px solid; 
    margin-left: 1px; 
    color: #34a4b5; 
    font-weight: bold; 

} 


a:link { 
    color: #34a4b5; 
    text-decoration: none; 
} 
#dpb { 
    display: inline-block; 
    float: left; 
} 

#clear_footer { 
    clear: both; 
    padding-top: 30px; 

} 

#container { 
    width: 980px; 
    margin: 0 auto; 
} 

#footer { 
    background-image: url('img/bottom_bar.jpg'); 
    width: 100%; 
    height: 3px; 
    clear: both; 

} 

.content-main-bottom { 
    padding-bottom: 10%; 
} 

/* Images .classes */ 

.header { 
    background-image: url('img/titan_header.jpg'); 
    background-repeat: no-repeat; 
    padding-top: 40px; 
    /*Size properties */ 
    width: 980px; 
    height: 143px; 
} 

.bubble_email { 
    background-image: url('img/speech_bubble.jpg'); 
    background-repeat: no-repeat; 
    /*Size properties*/ 
    width: 244px; 
    height: 49px; 

    /*Misc Prop*/ 
    background-repeat: none; 
    border: none; 
    outline: none; 
    padding-top: 0px; 
    margin-top: 6px; 
    padding: 0 6px; 


} 

.chairs { 
    background-image: url('img/titan_chairs.jpg'); 
    background-repeat: no-repeat; 
    /*Size properties*/ 
    width: 559px; 
    height: 400px; 
    margin-left: 50px; 
    margin-top: 40px; 
} 

.tweet { 
    background-image: url('img/tweet_button.jpg'); 
    background-repeat: no-repeat; 
    /*Size properties*/ 
    width: 368px; 
    height: 72px; 
    float: right; 
} 

謝謝

+0

爲它創建小提琴...沒有問題,它適用於我的Chrome 32 .. – Sam1604

+0

仍然無法正常工作。它只是不斷從圖像中脫穎而出。 – user3274696

+0

使用*固定*'寬度'輸入框 –

回答

0
.bubble_email 
     { 
      background-image: url('img/speech_bubble.jpg'); 
      background-repeat: no-repeat; /*Size properties*/ 
      width: 244px; 
      height: 49px; /*Misc Prop*/ 
      background-repeat: none; 
      border: none; 
      outline: none; 
      padding-top: 0px; 
      margin-top: 6px; 
      padding: 0 6px; 
     } 

你剛纔下降寬度至240以下的.bubble_email

OR

.bubble_email

OR

彈力添加padding-right: 15px;以上的背景圖像類似,

background-size:260px 50px; 
background-repeat:no-repeat; 
+0

您需要減小寬度,而不是增加!因爲添加填充固有地增加了寬度 - 因此您需要從輸入寬度中減去水平填充以保持其與圖像大小相同。 – Sam

0

好了,所以這裏的問題是,你要明白,當你添加填充右: 20;並且寬度設置爲244px,那麼您的輸入字段將變爲264px寬,正確填充20px,而不是244px,正如您所假設的那樣填充20px。所以,要解決您的問題,您需要添加一個正確的填充10px,並使輸入的寬度爲234px。

基本上只要你的輸入寬度+填充左邊+填充右邊等於你的背景圖像的寬度,你就會得到想要的效果。

解(假定圖像是250像素寬):

.bubble_email { 
    background-image: url('img/speech_bubble.jpg'); 
    background-repeat: no-repeat;    
    height: 49px; 
    background-repeat: none; 
    border: none; 
    outline: none; 
    margin-top: 6px; 

    width: 238px; 
    padding: 0 6px; 
} 

注所述寬度238 + a的6上的左,右側= 250像素填充和6。

希望這會有所幫助。

0

把sppech氣泡圖像中的一個類,像這樣:

.speechBubbleImage { 
background-image: url('img/speech_bubble.jpg'); 
} 

然後把其餘在另一個類中,並改變寬度,像這樣:

.innerSpeechBubble 
    { 
     background-repeat: no-repeat; /*Size properties*/ 
     width: 200px; /* This is what you change */ 
     height: 49px; /*Misc Prop*/ 

     background-repeat: none; /* This is redundant and I recommend don't use this */ 

     border: none; 
     outline: none; 
     padding-top: 0px; 
     margin-top: 6px; 
     padding: 0 6px; 
    } 

沒有IMG/speech_bubble.img圖片,它很難告訴你要放寬什麼寬度。

現在,在HTML用這個,像這樣

<div class='.speechBubbleImage"> 
<input type="email" class="innerSpeechBubble"> 
</div> 

<input type="submit" name="sub" value="Notify me!" class="button"> 

這應該工作。讓我知道你得到了什麼。如果可能的話給出圖像,這樣我就可以把確切的寬度。

+0

問題在於,他(或她)從輸入的填充寬度(填充:0 6px;)減去6px,但實際上需要左側減去12px - 6px,右側減去6px。所以寬度應該是238px,而不是244px。無需分開課程,這只是一個簡單的錯誤計算:) – Sam

-1

嘗試使用可能會解決此問題的隱藏溢出。