Results 1 to 6 of 6

Thread: responsive box model with border and text inside the div

  1. #1
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Question responsive box model with border and text inside the div

    On this page I have a div with a border and background color. It is where it starts to say "The following scholarship applications are to be filled out online"


    How can I get it so that the border is responsive and fits inside of the white container, not going all the way to the end on the right like it does now?
    Another of my members changed the page to add the new scholarships links there. I would also like to have a small radius on the box too. I looked into css box models but couldn't quite adapt the code to make it work the way I am asking for properly.

    Code:
    <div style="padding:10px;border:2px solid #333;background:#efefef;">
    Click image for larger version. 

Name:	box.JPG 
Views:	428 
Size:	45.6 KB 
ID:	5657

    thank you,
    Mike

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Something like this?
    Code:
    <div style="position: relative; width: 500px; height: 400px; background: black; margin: auto">
    <div style="position: absolute; left: 2%; top: 2%; right: 2%; bottom: 2%; border: 1px solid black; border-radius: 15px; background: white; padding: 10px">
    text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 
    </div>
    </div>
    Or this?
    Code:
    <div style="position: absolute; left: 10%; top: 10%; right: 10%; bottom: 10%; background: black">
    <div style="position: absolute; left: 2%; top: 4%; right: 2%; bottom: 4%; border: 1px solid black; border-radius: 15px; background: white; padding: 10px">
    text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 
    </div>
    </div>

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

    mlegg (04-08-2015)

  4. #3
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there mlegg,

    I am really surprised that you have not tried changing this...
    Code:
    
    #content {
        padding: 0px 0px 10px 10px;
        clear:both;
        position:relative;    
     }
    ...to this...
    Code:
    
    #content {
        padding: 0 10px 10px;
        clear:both;
        position:relative;    
     }

    coothead

  5. The Following User Says Thank You to coothead For This Useful Post:

    mlegg (04-08-2015)

  6. #4
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Default

    Thanks guys. I was just thinking of the change to the inline css for that part on the html page.

  7. #5
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there mlegg,

    I notice that you have added an unnecessary "px" here...
    Code:
    
    #content {
        padding: 0 10px 10px;
        clear:both;
        position:relative;    
     }
    You could equally have added " pt, in, pc, cm or mm" and got the same result.

    coothead

  8. #6
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Default

    LOL OOPS

Similar Threads

  1. Simple Controls gallery IE border on inside?
    By timondeks in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 11-16-2009, 12:23 PM
  2. Resolved Table border on inside
    By hosdank in forum HTML
    Replies: 3
    Last Post: 10-01-2009, 11:50 AM
  3. Text going out of border - Please Help
    By me_myself in forum CSS
    Replies: 2
    Last Post: 10-08-2008, 06:40 PM
  4. Replies: 4
    Last Post: 02-15-2008, 06:16 AM
  5. Replies: 4
    Last Post: 10-13-2006, 10:49 AM

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
  •