Results 1 to 3 of 3

Thread: Content editable div reduce line spacing

  1. #1
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default Content editable div reduce line spacing

    Hello everyone,

    This is my code

    HTML Code:
    <HTML>
    <HEAD>
    </HEAD>
    <BODY STYLE="overflow:hidden; margin:0px; background-color:grey;">
    <DIV ID="oDiv" CONTENTEDITABLE STYLE="height:60%; background-color:white; overflow:auto; width:30%; line-height:10%;"> 
    </DIV>
    </BODY>
    </HTML>
    Is there any way to remove the giant spacing between each line in the div?
    I've tried css line-height.
    Keyboard1333
    Last edited by keyboard; 02-08-2012 at 11:53 PM. Reason: Cause I can't use bbcode properly...

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Firefox 'gets it right' IE inserts a p for each line break from the enter key, Firefox a br tag. You can use style in the head of the page to 'fix' IE, or just don't hit the enter key unless you want a new paragraph.

    The 'fix':

    Code:
    <style type="text/css">
    #oDiv p {
    	margin: 0;
    }
    </style>
    Full demo:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
    html, body {
    	height: 100%;
    }
    body {
    	overflow: hidden;
    	margin: 0px;
    	background-color: gray;
    }
    #oDiv {
    	height: 60%;
    	background-color: white;
    	overflow: auto;
    	width: 30%;
    }
    #oDiv p {
    	margin: 0;
    }
    </style>
    </head>
    <body>
    <div id="oDiv" contenteditable></div>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    keyboard (02-08-2012)

  4. #3
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •