Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

1/05/2016

Loading CSS Styleheet in IE8, E7, and IE6 Dynamically

Since innerHTML doesn't work in IE8 and below. Here is a hack for inserting CSS Styleheet in IE8 using javascript programmatically.
  var css = 'body {color:red}';
  var style = document.createElement('style');
  style.setAttribute("type", "text/css");
  var head = document.getElementsByTagName('head')[0];
  head.appendChild(style);
  if (style.styleSheet) {   // IE
    style.styleSheet.cssText = css;

  } else {  // modern browser
    var node = document.createTextNode(css);
    style.appendChild(node);
  }

5/21/2014

[CSS] Force a Long Line of Word (without spaces) to Line Break

Suppose you have a very long word in DIV as below, the word will not break by default.
<div id="veryLongWord">VeryLongWordVeryLongWordVeryLongWord</div>
<style>    
  #veryLongWord{
    border-style:double;
    width: 250px;
  }    
</style>
Result:
VeryLongWordVeryLongWordVeryLongWord

If you'd like to make a long word have Line Breaks, just add word-wrap:break-word; to your css like:

<div id="breakWord">VeryLongWordVeryLongWordVeryLongWord</div>
<style>    
  #breakWord{
    border-style:double;
    width: 250px;
    word-wrap:break-word;
  }    
</style>
Result:
VeryLongWordVeryLongWordVeryLongWord