Flickering on hover over div - html

I'm trying to use a background color with some opacity on hover over a div. But i get flickering effect over the color once i hover over it. while as the element i hover over is working properly.
My code and css is as below:
<div class="flip-menu">
<section class="flip-item-wrap">
<img class="fake-image" src="http://lorempixel.com/500/500/food/11" alt=""><!-- this image will add height to parent element -->
<input type="checkbox" class="flipper" id="a">
<label for="a" class="flip-item">
<figure class="front"><img class="img_hover" src="http://lorempixel.com/500/500/food/1" alt=""></img>
</figure>
<figure class="back">
<img src="http://lorempixel.com/g/500/500/food/1" alt=""></img>
<div class="flip-item-desc">
<h4 class="flip-item-title">Lorem ipsum dolor</h4>
<p>Dolor sit amet, consectetur adipiscing elit. Vestibulum posuere turpis lacus.</p>
</div>
</figure>
</label>
<div style="background: none repeat scroll 0 0 #FFFFFF;
color: #000000;
left: 1px;
opacity: 0.8;
padding: 4px;
position: absolute;
text-transform: uppercase;
top: 162px;
width: 182px;
z-index: 9999;
left: 0px;
overflow:hidden;" class="hover_div">
hhh
</div>
</section>
</div>
.img_hover:hover{
border:1px solid #888888!important;
}
.hover_div{
display:none;
}
.flip-item-wrap :hover + div{
display: block;
cursor:pointer;
}

I think I understand what you are trying to do. The confusion here arose because in testing your code there is an obvious flicker on the image's border, and that's what Yasser was trying to fix - which he did. But I think you are referring to something else. I suggest starting from scratch and cleaning your code up, that will make things easier - this alone will probably solve your problem. I made a fiddle that accomplishes what I believe you are after.
This should get you started in the right direction.
<style>
.main {
width:500px;
height:500px;
}
.cover {
position:absolute;
background:#ccc;
opacity:.5;
width:500px;
height:500px;
display:none;
}
.main:hover .cover {
display:block;
}
</style>
<div class="main">
<div class="cover"> </div>
<img class="img_hover" src="http://lorempixel.com/500/500/food/1" alt="">
</div>
JSFiddle

I am assuming the flickering to be the border which comes up and shakes the layout a bit. Add this line of css and let me know if this works for you.
.img_hover{
border:1px solid #fff !important;
}
Atlernatively you should add a jsfiddle so that we could help you better.
Edit:
A better way to do this would be this - Thanks Ruddy
.img_hover:hover {
outline:1px solid #888888!important;
}

Related

How can I have consistent spacing between my images?

I am trying to use CSS to obtain consistent spacing between my images that are listed in the skills section of the HTML code. This is the Code:
.skilllogos {
height: 100px;
width: 100px;
}
.jslogo {
padding-left: 14px;
}
<div class="skill-row">
<img class="skilllogos" src="images/html.svg" alt="html-icon">
<img class="skilllogos" src="images/css3.svg" alt="css-icon">
<img class="skilllogos jslogo" src="images/javascript.svg" alt="javascript-icon">
</div>
Adding the padding to the jslogo does seem to solve the problem (that is how i tried to fix it) but it seems like I'm putting on duck tape to fix the issue and there is probably a better way to do this. If I change the height and width of the images then the spacing will become inconsistent again, it's sort of hard coded and I do not want that. If you haven't guessed already, I am very new to web development so your help is very much appreciated! Thank you!
I think this is what you're looking for
.skilllogos {
height: 100px;
width: auto;
}
.skilllogos:not(:last-of-type) {
padding-right: 14px;
}
<div class="skill-row">
<img class="skilllogos" src="images/html.svg" alt="html-icon">
<img class="skilllogos" src="images/css3.svg" alt="css-icon">
<img class="skilllogos" src="images/javascript.svg" alt="javascript-icon">
</div>
try this
instead of adding padding-left add padding to all
body{
background :#111;
margin:20px auto;
text-align:center;
}
.skill-row{
padding:10px;
background:#fff;
}
.skill-row img{
padding:14px;
border:1px solid #111;
}
<div class="skill-row">
<img class="skilllogos" src="https://dummyimage.com/100x100/de4242/fff.svg&text=+HTML+5+" alt="html-icon">
<img class="skilllogos" src="https://dummyimage.com/100x100/de4242/fff.svg&text=+CSS+3+" alt="css-icon">
<img class="skilllogos jslogo" src="https://dummyimage.com/100x100/de4242/fff.svg&text=+JS+5+" alt="javascript-icon">
</div>
Added border to know the space bwteen images by adding js logo only instead add all logo by
.skilllogos {
height: 100px;
width: 100px;
border:2px solid #111;
padding:14px;
}
<div class="skill-row">
<img class="skilllogos" src="https://dummyimage.com/100x100/de4242/fff.png&text=+HTML+5+" alt="html-icon">
<img class="skilllogos" src="https://dummyimage.com/100x100/de4242/fff.png&text=+CSS+3+" alt="css-icon">
<img class="skilllogos jslogo" src="https://dummyimage.com/100x100/de4242/fff.png&text=+JS+5+" alt="javascript-icon">
</div>

Hover parent-element shall edit child-elements look - not working

I have several figure-elements where I want to add some simple hover-effect to the caption when hovering the parent-container. But that doesn work out, neither with > nor in the way shown below, what do I do wrong there?
.kategorie_container .product_caption{
margin:0;
width:100%;
position: absolute;
padding: 1vh 2vw;
bottom: 0;
background:white;
transition: 0.2s;
}
.kategorie_container figure:hover .kategorie_container .product_caption {
background:blue;
}
And this is the markup-structure of it:
<figure class="col col-3 ">
<a href="#">
<img src="assets/media/raster/active-pro80-dose_1.jpg" />
<div class="product_caption">
<h6 class="produktname">Productname</h6>
<h6 class="produktpreis">Productprice</h6>
</div>
</a>
</figure>
Thanks!
There is no element with the class "kategorie-container" inside your figure. I think you meant to write
.kategorie_container figure:hover .product_caption {
background:blue;
}

HTML Text not showing over Image

My text/header is not showing over my image which I'm trying to use as a background to this webpage. This is the code I have right now:
HTML:
<body id="body">
<div id="navbar">
<h1 id="name">Lorem ipsum</h1>
<img class="backgroundimg" src="leaf.jpg" alt="A leaf"/>
</div>
<div class="backimg">
<img class="backgroundimg" src="buildings.jpg"/>
</div>
<div class="backimg">
<img class="backgroundimg" src="squares.jpg"/>
</div>
</body>
CSS:
body {
background-color:black
}
backgroundimg {
position:relative;
width:1175px;
}
name {
position:absolute;
color: white;
z-index;
}
Any tips?
P.S. I took out the '#' and '.' to the appropriate names in CSS.
Use z-index to show the text over image.
You can use z-index, like Anil Panwar said(https://stackoverflow.com/a/34374513/4900669)
#name {
position:absolute;
color: white;
z-index: 10;
}
https://jsfiddle.net/08voh0fp/
Add this to your css file
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
adjust top,left and width according your need,
let me know if this helped

div not expanding error

im havin this error, in which my div doesnt expand
the line on top is the div, which is supposed to be surrounding the images and the text that you can see
heres the code:
html
<div class="team sizer">
<img class="teamtitle" src="FullWeb/v_landingpage/Title.png"/>
<div class="person1 pimage">
<img src="FullWeb/v_landingpage/Team_Pic_Base.png"/>
<p class="ptext">Person 1</p>
</div>
<div class="person2 pimage">
<img src="FullWeb/v_landingpage/Team_Pic_Base.png"/>
<p class="ptext">Person 2</p>
</div>
<div class="person3 pimage">
<img src="FullWeb/v_landingpage/Team_Pic_Base.png"/>
<p class="ptext">Person 3</p>
</div>
<div class="person4 pimage">
<img src="FullWeb/v_landingpage/Team_Pic_Base.png"/>
<p class="ptext">Person 4</p>
</div>
<p class="pagebottomtext" width="44.21052631578947%">Lorem ipsum</p
</div>
css:
.team{
position:relative;
margin-bottom:700px;
border: 1px solid black;
}
.teamtitle{
position:absolute;
top:1%;
left:47.15789473684211%;
width:5.684210526315789%;
height:42px;
border: 1px solid black;
}
.pimage{
position:absolute;
top:120px;
border: 1px solid black;
}
.person1{
left:530px;
}
.person2{
left:770px;
}
.person3{
left:1010px;
}
.person4{
left:1250px;
}
.ptext{
font-family: Lucida Sans Unicode;
color:#999999;
font-size:1.1em;
border: 1px solid black;
}
.pagebottomtext{
position:absolute;
text-align:center;
width:44.21052631578947%;
top:320px;
left:27.89473684210527%;
font-family: Lucida Sans Unicode;
color:#999999;
}
thanks in advance for your help.
http://jsfiddle.net/UPsew/3/
It's because all the child elements of the div have position: absolute, and hence are taken out of the flow (i.e. they don't take up any space within the containing div, and hence it shrinks to zero height).
You'll need to position them using something else. I had a little play and came up with this using margins to position:
http://jsfiddle.net/UPsew/7/
although you'll probably need to mess with the numbers.
Try adding overflow:hidden to the "team" class.
I'm not very sure that's the case, especially that your HTML isn't complete. If this doesn't work, please add your code on jsfiddle.

perfect way to displaying images

I am new to css . I am trying to display my images in a perfect manner
here is my html code:
<div id="photos">
<h3>Photo title</h3>
<P class="like">Like </P>
<p class="date">date </p>
<div id="image">
<img src="something.jpg" />
</div>
<p class="about">about image goes here</p>
</div>
Now i want to style the same like this:
http://www.desolve.org/
If you want to make your image like that wall post i did it in below given fiddle link.
http://jsfiddle.net/zWS7c/1/
Css
#photos{
margin:10px;
border:solid 1px red;
font-family:arial;
font-size:12px;
}
#photos h3{
font-size:18px;
}
.date, .like{
text-align:right;
}
.about{
margin:10px;
}
#image img{
width:100%;
}
HTML
<div id="photos">
<h3>Photo title</h3>
<P class="like">Like </P>
<p class="date">date </p>
<div id="image">
<img src="http://www.desolve.org/_images/chicago_banner.jpg" />
</div>
<p class="about">about image goes here</p>
</div>
Live demo http://jsfiddle.net/46ESp/
and now set to according to your layout as like margin *padding* with or height
I think you need like this
http://jsfiddle.net/VwPna/
From http://www.w3schools.com/css/default.asp you learn easily... and also you can check other website css from firebug in your browser.
below code is that you given site css for banner class.
.banner {
background: url("../_images/gallery_banner.jpg") no-repeat scroll 0 0 transparent;
height: 350px;
margin-bottom: 4em;
overflow: hidden;
padding-left: 3.9%;
position: relative;
}
same way you can give more style their.
Here is the way it is made on the link you gave.
HTML:
<div class="banner">
<h1>We love urban photography</h1>
<p>
We’re betting you do to. Welcome to our site, a growing collection of galleries taken by a small group of passionate urban photographers. Visit our galleries, buy some of our prints, or drop us a line. While you’re at it, feel free to submit a gallery of your own.
<strong>Welcome</strong>
.
</p>
</div>
CSS:
.banner {
background: url("../_images/gallery_banner.jpg") no-repeat scroll 0 0 transparent;
height: 350px;
margin-bottom: 4em;
overflow: hidden;
padding-left: 3.9%;
position: relative;
}
.banner h1 {
color: #FFFFFF;
font-size: 2.2em;
letter-spacing: 0.1em;
padding-top: 290px;
}
.banner p {
background: none repeat scroll 0 0 rgba(123, 121, 143, 0.8);
color: #FFFFFF;
font-size: 1em;
height: 350px;
padding: 1% 1% 0;
position: absolute;
right: 0;
top: 0;
width: 21%;
}
You only need to translate that to your id's, classes and form, then you have it
There's nothing special that they've done on the reference web site. They've used the image as a background property of a div class="preview".
Here is the (x)HTML:
<section class="chicago">
<h2>Chicago</h2>
<p class="pubdate">
<time datetime="2011-04-24" pubdate="">April 2011</time>
</p>
<div class="preview"></div>
<p class="caption">Big wind, big shoulders. See a different side of Chicago.</p>
</section>
And the corresponding CSS
.chicago .preview {
background: url(../_images/sm_chicago_banner.jpg) no-repeat;
}
You can always sneak-peek by right mouse click on the website and choosing "View Page Source" or something similar, depending on your browser :)