Results 1 to 6 of 6

Thread: How do I keep text over image when page is zoomed?

  1. #1
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default How do I keep text over image when page is zoomed?

    I have the following:

    HTML
    Code:
    	<div class="content">
        <div class="textbg">
         <img src="bg400x400.jpg" width="600px" height="990px">
            <div class="textinbox">
      <!-- text goes here -->
    and the CSS

    Code:
    .content
    {
    float: left;
    width: 60%;
    padding-left: 0.5%;   
    }
    .textbg {
    position: relative; 
    width: 100%;
    padding-left:10px;
    }
    .textinbox {
    position: absolute; 
    top: 20px; 
    left: 20; 
    width: 90%;
    padding-left:30px; 
    padding-top:10px;
    }
    If I zoom in or out, the text overflows the image container. How can I force the text to always stay inside the image div?
    Cheers
    Billy

  2. #2
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    I would say your problem involves your use of absolute positioning in
    HTML Code:
    .textinbox
    . Do you have a link to the page? Also are you sure that the
    HTML Code:
    </div>
    tags are properly nested?

  3. #3
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Page is at:
    proweb4u.com/test.shtml

    If I don't use position absolute, the text displays below the image
    Cheers
    Billy

  4. #4
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    Try this

    change your .textbg { width:600px;}
    then adjust your padding to center in your .textinbox

    Looks good to me in Firefox and Opera.

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

    wkenny (09-15-2011)

  6. #5
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Brilliant - that does the trick. Thanks a bunch.
    Cheers
    Billy

  7. #6
    Join Date
    Mar 2007
    Location
    Dublin, Ireland
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I'm glad it works. You could also try using z-index properties and set the text a higher z-index than the image.

    Example:

    Code:
    text { z-index: 100; }
    image { z-index: 99; }

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
  •