Reputation: 22580
I am trying to create a responsive container which contains an image and a div with some text over the image. Something like this:
.tileimage {
position: absolute;
width: 100%;
height:auto;
color: white;
}
.tileseven {
position: absolute;
width: 100%;
height:auto;
}
<div className="container">
<img className="col-lg-12 tileimage" src="./tile.jpg" alt=""/>
<div className="col-lg-12 tileseven">
<img className="" src="./logo.png" alt=""/>
<p>this is some text</p>
</div>
</div>
How can I make the logo.png
responsive? When I resize the browser the image is resized but not the logo? Also how can I keep the div.tileseven
superimposed over the image at the bottom?
Upvotes: 1
Views: 140
Reputation: 270
Take a look at this!!!Try to test this. //
<!DOCTYPE html>
<html>
<head>
<style>
div.gallery {
border: 1px solid #ccc;
}
div.gallery:hover {
border: 1px solid #777;
}
div.gallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 15px;
text-align: center;
}
* {
box-sizing: border-box;
}
.responsive {
padding: 0 6px;
float: left;
width: 24.99999%;
}
@media only screen and (max-width: 700px){
.responsive {
width: 49.99999%;
margin: 6px 0;
}
}
@media only screen and (max-width: 500px){
.responsive {
width: 100%;
}
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
</style>
</head>
<body>
<h2>Responsive Image Gallery</h2>
<h4>Resize the browser window to see the effect.</h4>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="img_fjords.jpg">
<img src="img_fjords.jpg" alt="Trolltunga Norway" width="300" height="200">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="img_forest.jpg">
<img src="img_forest.jpg" alt="Forest" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="img_lights.jpg">
<img src="img_lights.jpg" alt="Northern Lights" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="img_mountains.jpg">
<img src="img_mountains.jpg" alt="Mountains" width="600" height="400">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div>
<div class="clearfix"></div>
<div style="padding:6px;">
<p>This example use media queries to re-arrange the images on different screen sizes: for screens larger than 700px wide, it will show four images side by side, for screens smaller than 700px, it will show two images side by side. For screens smaller than 500px, the images will stack vertically (100%).</p>
</div>
</body>
</html>
Upvotes: 1
Reputation: 216
You can make the logo responsive by defining it's width 100%. Below is the css:
.tileseven img {
width: 100%;
}
To make div.tileseven superimposed play with left, top and z-index in CSS.
Upvotes: 0
Reputation: 85
For the resizing of the logo you will need to reference the image not just the containing div
.tileseven img {
height: auto;
width: 100%;
}
as for keeping it on top, you could always throw a z-index in there.
Upvotes: 0