I am working on a responsive template. I have pages with images and I want them to look like this : http://www.chanel.com/fr_FR/
I can't figure out a css way to achieve it so I am trying jquery although I ain't the best jquery coder...
This is what I end up with : html
<html>
<body>
<div class="text" >
<p>some text</p>
<div>
<div class="image" >
<img class="adapt" src="my-image.jpeg" alt="my image">
</div>
</body>
</html>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
function imageResize() {
var wrapH = $('div.image').height();
var imgH = $('img.adapt').height();
var wrapW = $('div.image').width();
var imgW = $('img.adapt').width();
$("img.adapt").css("height", (wrapH < imgH) ? wrapH : "auto");
$("img.adapt").css("width", (wrapW < imgW) ? wrapW : "auto");
}
imageResize();
$(window).bind("resize", function(){
imageResize();
});
});
</script>
css
div.text {
position : absolute;
width : 40%
left : 0;
top : 0;
}
div.image{
position: absolute;
top : 0;
right : 0;
left : 40%;
width : 60%;
bottom : 150px;
}
This seems to work when I enlarge the browser but when I make it smaler, the image flickers and its ugly...
If some pro jquery coder can explain this problem to me, I would be very graitfull.