I have a section inside which there is an image of a fixed height and a div which has some text and a background color in it. I want to make the height of the div and the image same and the div with the background color to overlap the image so that only text and background color are seen and not the image but the height should be of the image.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<section>
<img src="http://drkeyurparmar.com/wp-content/uploads/2015/02/dummy-article-img-1.jpg" class="img-responsive">
<div style="background-color:blue">
<h2>ABCD</h2>
</div>
</section>
The image has a bootstrap class of img-responsive so that on resize it shrinks and also the div along with it. How can I do this?
position properties will work same as you want. section will take img's height and by setting height:100%; and position:absolute to div, it will take same height as img
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
section {
position: relative;
}
div {
position:absolute;
left:0;
top:0;
height:100%;
width:100%;
}
</style>
<section>
<img src="http://drkeyurparmar.com/wp-content/uploads/2015/02/dummy-article-img-1.jpg" class="img-responsive">
<div style="background-color:blue">
<h2>ABCD</h2>
</div>
</section>
Please have a link of your solution
http://codepen.io/santoshkhalse/pen/pNWpYd
<section>
<img class="img-height" src = "https://openclipart.org/image/2400px/svg_to_png/28688/skotan-Thumbs-up-smiley.png" class = "img-responsive">
<div class="content-text">
<h2> Your text will render here </h2>
</div>
</section>
.img-height{
height:100px;
position:absolute;
}
.content-text{
width:100%;
height:100px;
background:green;
padding-left:120px;
}
img{ display:block; max-width:100%; height:auto;}
section{ position:relative}
.overlap-text{background:rgba(0,0,0, 0.5); color:#fff; position:absolute; left:0; top:0; height:100%; width:100%;}
<section>
<img src="https://s-media-cache-ak0.pinimg.com/originals/2a/94/e3/2a94e33f7afe6600fe9c97eda3a386b3.jpg" class="img-responsive"/>
<div class="overlap-text">
<h2>Lorem Ipsum dummy text</h2>
</div>
</section>
Related
I have used a wrapper class to put an image and some text together. I want the functionality that the text remains invisible but whenever I hover over the image, the text becomes visible and the image's opacity decreases and the text appearing on the image should have more opacity than the Image.
However, the code which I have written , decreases the opacity of Image on hovering and also makes the opacity of the text equal to that of Image. What should I do in order to ensure that the opacity of text and image remain different ?
/*Portfolio Section*/
html {
font-size:12px;
}
section{
display:flex;
justify-content:center;
flex-wrap:wrap;
height:auto;
width:90vw;
margin:auto;
}
#portfolio-header span{
color:blue;
font-size:3rem;
display:inline-block;
margin-top:1rem;
margin-bottom:2rem;
}
.portfolio-images{
display:flex;
width:100%;
flex-wrap:wrap;
justify-content: space-evenly;
}
.wrapper img{
width:25rem;
height:20rem;
display:inline-block;
}
.wrapper{
position:relative;
width:25rem;
height:20rem;
margin-bottom:0.8rem;
}
.img_description{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
color:white;
visibility:hidden;
opacity:0;
transition: opacity .2s,visibility .2s;
}
.wrapper:hover img{
background-color:lightgray;
opacity:0.4;
}
.wrapper:hover .img_description{
visibility:visible;
opacity:1;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="portfolio.css">
<script src="https://kit.fontawesome.com/15a25df2f9.js" crossorigin="anonymous"></script>
</head>
<body>
<section id="portfolio">
<div id="portfolio-header">
<span><i class="fas fa-align-justify"></i></span>
<span>Portfolio</span>
</div>
<div class="portfolio-images">
<div class="wrapper">
<img src="Picture1.png" alt="picture">
<p class="img_description">Write Here Basic Details About The Picture.</p>
</div>
<div class="wrapper">
<img src="Picture1.png" alt="picture">
<p class="img_description">Write Here Basic Details About The Picture.</p>
</div>
<div class="wrapper">
<img src="Picture1.png" alt="picture">
<p class="img_description">Write Here Basic Details About The Picture.</p>
</div>
<div class="wrapper">
<img src="Picture2.png" alt="picture">
<p class="img_description">Write Here Basic Details About The Picture.</p>
</div>
<div class="wrapper">
<img src="Picture2.png" alt="picture">
<p class="img_description">Write Here Basic Details About The Picture.</p>
</div>
<div class="wrapper">
<img src="Picture2.png" alt="picture">
<p class="img_description">Write Here Basic Details About The Picture.</p>
</div>
</div>
</section>
</body>
</html>
I am using a SVG image over that image I need to have a div over the image to set a button area over the image. I have placed a div content in my html file but my image file hides the div content. How to make it?
This my html code:
<div class="fancybox" id="nav" href="#inline1"/>
<img src="billing.svg" id="my_image" class="gold1"/>// this is my image over this I need to place the div content
This is my CSS file:
#nav {
line-height:30px;
background-color:#00FF66;
height:400px;
width:200px;
float:left;
padding:9px;
}
.fancybox{
position:relative;
height://height go image
width:// of image
}
.fancybox img{
position:absolute;
height://height go image
width:// of image
z-index:-1;
}
.myDiv{
position:absolute;
width:// width of dive
z-index:1;
left://margin from left
right://margin right
top:margin from top
bottom:margin from bottom
}
<div class="fancybox" id="nav" href="#inline1"/>
<img src="billing.svg" id="my_image" class="gold1"/>
<div class="myDiv"></div>
</div>
<div class="outerBoxContent">
<div class="fancybox" id="nav" href="#inline1"/>
<img src="billing.svg" id="my_image" class="gold1"/>// this is my image over this I need to place the div content
</div>
css
.outerBoxContent{position: relative;}
.outerBoxContent .fancybox{position: absolute;top: 0px;left: 0px;height: 100%;width: 100%:z-index:123}
This is how you can place the content over a div.
Below is my code :
<div id="footer">
<div id="left_footer">
<div id="img_left" align="center">
<img src="separator_bar.jpg" align="middle"/>
</div>
</div>
<div id="right_footer">
<div id="img_right" align="center">
<img src="separator_bar.jpg" align="middle"/>
</div>
</div>
</div
CSS:
#footer {
width:500px;
position:relative
}
#left_footer{
float:left;
}
#right_footer{
float:right;
}
I am trying this code but my image is not aligned to center its always aligned to left in left footer and to right in right footer. Please suggest !
I would approach the layout like this:
http://jsfiddle.net/yWmZ5/1/
HTML
<div id="footer">
<div id="left_footer">
<img src="http://placekitten.com/100/100" />
</div>
<div id="right_footer">
<img src="http://placekitten.com/100/100" />
</div>
</div>
CSS
#footer { width:500px; position:relative; overflow:hidden; }
#left_footer{ width:250px; float:left; text-align:center; background:orange; }
#right_footer{ width:250px; float:right; text-align:center; background:yellow; }
Make sure you strip all styling (eg - align, etc) out of your HTML and put it in your CSS.
Try this style:
#footer > div{width:50%}
your div#left_footer and div#right_footer need to have some width, in order to display the content in the middle
change your corresponding css to this:
#left_footer{
text-align:center;
float:left;
width:50%;
}
#right_footer{
float:right;
width:50%;
}
see this fiddle
I'm trying to achieve an effect when one div with png img inside (this img has hole in it) is over another div with img inside that will appear in hole of image over it, but for now it still is over instead of being under img with "window". And I still want to keep div that has to be under img ("iphone-screen") inside div with image with window ("iphone") because of responsive issues (percentage width of inner div is related to width of outer div). How to achieve that? Here's link to my website (go to page "Kontakt"):
CLICK
And here's my HTML markup:
<div id="slide6" class="slide">
<h1 class="big">Kontakt</h1>
<h2 class="call">Zadzwoń: <span class="thick">514 944 555</span></h2>
<h2 class="mail">
Napisz: <span class="thick">biuro#dentmedica.pl</span>
</h2>
<div id="iphone">
<img src="img/iphone.png" alt="" />
<div id="iphone-screen">
<img src="img/iphone-screen.png" alt="" />
</div>
</div>
</div>
And CSS:
#slide6 #iphone{
position:absolute;
bottom:0;
right:0;
width:40%;
z-index:600;
}
#slide6 #iphone > img{
width:100%;
height:auto;
z-index:600;
}
#slide6 #iphone #iphone-screen{
position:absolute;
width:44.1%;
overflow:hidden;
bottom:24%;
left:15%;
z-index:100;
}
#slide6 #iphone #iphone-screen > img{
width:100%;
height:auto;
z-index:100;
}
Thanks for any help!
I guess it's the issue with the div tag iphone-screen..remove it
I have 1 div wrapping h2 and image wrapped in div with class img. h2 is float:left and img float:right.
img div has image inside. What I want is
if image is height and width 100px than its not vertical-align:middle. Help please.
Tested with vertical-align:middle
CSS
.ver-mainbox{float:left; width:898px; border:1px solid #c3c3c3; padding:0px; height:122px; margin-bottom:15px; background-color:#ffffff;}
.ver-mainbox h2{font-size:18px;color:#000; padding-left:10px; margin:0px; vertical-align:middle; width:500px; float:left; padding-top:42px;}
.ver-mainbox .img{float:right; padding:0px; width:186px; height:122px;}
HTML
<div class="mainbox-area">
<!-- Box start v1 -->
<div class="ver-mainbox">
<h2>Immunizations</h2>
<div class="img"><img src="../../Content/images/v1.gif" alt="" title="" /></div>
</div>
<!-- Box start v1 -->
</div>
vertical-align is only applicable to table cells. You'll need to rethink how you go about this or use the display:table-* properties.
<div style="display:table">
<h2 style="display:table-cell;vertical-align:middle">Immunizations</h2>
<div style="display:table-cell;vertical-align:middle">
<img src="../../Content/images/v1.gif" alt="" title="" />
</div>
</div>