Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    219
    Thanks
    25
    Thanked 1 Time in 1 Post

    positioning text and width problem

    I've got an image from 196x196 px on my website.
    I've placed aa 196x30 px transparent div on top of it, on the bottom of the image.

    For some strange reason the transparent div hasn't got a width from 196px, how can I alter the coding so that the width will be 196px ?

    Second, how can I vertical align the text ? It looks okay on IE now, but if I test it with firefox the text is too high. I know I can set a margin for it, but then the text in IE would be too low.

    Code:
    <html>
    <head>
    <style type="text/css">
    
    div.transbox
    {
      width: 169px;
      height: 30px;
      margin: -37px 0px;
      background-color: lime;
      border: 0px solid black;
      filter:alpha(opacity=60);
      opacity:0.6;
      position: relative;
    
    }
    div.transbox p
    {
    
      margin: 5px 0px;
      font-weight: bold;
      color: #000000;
      text-align: center;
      
    }
    </style>
    </head>
    <body><div><img src="fcd4-3f08.jpg">
    <div class="transbox">
    <p>example text</p>
    </div></div>
    </body>
    </html>

  • #2
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    oh nice. so your trying to make an opacity filter.

    I would suggest absoluting the filter over the image.

    To vertical align: use line-height: (height of img) - line-height and height are the same measure, so you are setting an equal padding on the top and bottom.

    You could also use vertical-align http://www.w3schools.com/cssref/pr_p...ical-align.asp but I've always hated this

    Code:
    div.transbox {
    width: 169px;
    height: 30px;
    margin: -37px 0px;
    background-color: lime;
    border: 0px solid black;
    filter: alpha(opacity=60);
    opacity: 0.6;
    position: relative;
    }
    196!

    line height would be :

    Code:
    line-height: 3px0;
    -best regards


  •  

    Posting Permissions

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