Want to get CSS Text Wrap working in IE7

守給你的承諾、 提交于 2019-12-25 02:25:29

问题


The following code renders great in FF3 but doesn't work in IE7. Does anyone have an idea how to fix it?

<div style="padding-top:3px;padding-bottom:5px;width:650px;background:blue">
    <div style="height:50px;float:left;display:inline;width:500px;background:gray">http://www.brainsolis.com/2008/10/twitter-tools-for-comunity-and-love-for-...</div>
    <div style="width:100%;text-align:right;float-right;background:yellow">saaal is saaa twittertool ds ds dsdfsdsdfsdfsdfsdfsdfsd sdf dsf sdf sdf sdf sd ssssssssssssssssssssssssssssssssssssssssssssssssssss</div>
</div>

回答1:


You do not need to float an element, and display:inline at the same time. Additionally, you do not need to set width:100% for DIV elements. They will naturally take up all available horizontal space.

The following CSS should achieve what you are attempting.

div.container {

}
  div.floated {
    width:50px;
    float:left;
  }
  div.textbody {
    /* styles */
  }
  br.clear {
    clear:both;
    height:0;
    line-height:0;
  }

<div class="container">
  <div class="floated">
    <p>This is floated</p>
  </div>
  <div class="textbody">
    <p>...text body...</p>
  </div>
  <br class="clear" />
</div>

For more information on CSS, check w3schools, or watch the CSS Videos at SampsonVideos.




回答2:


I haven't checked your sample but this took care of IE wrapping problems for me:

div
{
  word-wrap: break-word;  /* for IE, force it to wrap text and keep it inside the div */
}



回答3:


the css word-wrap directive is working for me

tried in ie6, 7, 8 and chrome (as usual, firefox wrap my text correctly even without it)

seems to be an IE invention but also css3 compatible (http://www.css3.com/css-word-wrap/)



来源:https://stackoverflow.com/questions/458922/want-to-get-css-text-wrap-working-in-ie7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!