Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-16-2011, 05:15 PM   PM User | #1
docock
Regular Coder

 
Join Date: Feb 2007
Posts: 197
Thanks: 21
Thanked 1 Time in 1 Post
docock is an unknown quantity at this point
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>
docock is offline   Reply With Quote
Old 07-16-2011, 06:28 PM   PM User | #2
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
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
Sammy12 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:58 AM.


Advertisement
Log in to turn off these ads.