SoonYeoung
SoonYeoung

Reputation: 43

CSS image Size?

There...

#logoWrapper{
  background-image: url(../image/bg_img.jpg);
  height:86px;
  width:100%;
  }

Q> How to fix the size of the image get into #logoWapper same with its Wapper automatically?

#logoWrapper img{       // not work
  height:86px;
  width:100%;
  } 

Thank you!

Upvotes: 3

Views: 14937

Answers (1)

Wayne Smith
Wayne Smith

Reputation: 4868

For a background image in CSS3 if you want to stretch not repeat you can use background-size: 100%;

Documented here http://webdesign.about.com/od/styleproperties/p/blspbgsize.htm

Alternatively you can layer a absolute positioned image inside a relative positioned div and add an additional wrapper.

<style>
#wrapper {
position:relative;
...
}
#wrapper div, #wrapper img {
position:absolute;
top:0px;
left:0px;
...
}
</style>

<div id="wrapper">
<img ... >
<div> this goes on top of image</div>
</div>

Upvotes: 2

Related Questions