I am new to HTML and CSS, I have found out how to fade when mouseover, but when I mouseover, how can I add in text too? Here is my HTML and CSS:
HTML:
<div class="showTeams">
<p>Please, select a team you'd like to view:</p>
<table class="center">
<tr>
<th>
<div class="tZ"> <a href="#">
<img id="tz" src="../images/teamZeus-pic.png" class="hover item-fade" alt="team Zeus" title="team Zeus"/>
</a>
</div>
</th>
<th>
<div class="zC"> <a href="#">
<img src="../images/zeusCreations-pic.png" class="hover item-fade" alt="zeus Creations" title="zeus Creations"/>
</a>
</div>
</th>
</tr>
</table>
</div>
CSS:
.tZ {
display:inline-block;
background:#000;
}
.zC {
display:inline-block;
background:#000;
}
.item-fade {
vertical-align:top;
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
.hover:hover {
opacity:0.2;
}
I want text to come in at the same speed as the background fade. Thanks guys
I'm not sure if I understand what you want, but I tryed something so you can take a look to this:
<div class="showTeams">
<p>Please, select a team you'd like to view:</p>
<table class="center">
<tr>
<th>
<div class="tZ"> <a href="#">
<img id="tz" src="../images/teamZeus-pic.png" class="hover item-fade" alt="team Zeus" title="team Zeus"/>
</a>
<div id="hover-content">
Text shows only on mouseover
</div>
</div>
</th>
<th>
<div class="zC"> <a href="#">
<img src="../images/zeusCreations-pic.png" class="hover item-fade" alt="zeus Creations" title="zeus Creations"/>
</a>
</div>
</th>
</tr>
</table>
</div>
CSS:
.tZ {
display:inline-block;
background:#000;
}
.zC {
display:inline-block;
background:#000;
}
.item-fade {
vertical-align:top;
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
.hover:hover {
opacity:0.2;
}
#hover-content {
color: white;
display:block;
}
.tZ:hover #hover-content {
display:none;
}
here are two way to perform this with css (jsfiddle setup for css) and jquery (jsfiddle setup for jquery). youi can use any way to perform
with css you need to add text in th like
<h2 class="heading">This is heading</h2>
and css will
h2.heading {
position: absolute;
bottom: 101px;
color: #fff;
opacity:0;
margin-left: 99px;
}
th:hover .heading
{
opacity:1;
}
with jquery
add this style
h2.heading {
position: absolute;
bottom: 101px;
color: #fff;
display:none;
margin-left: 99px;
}
and script
$(document).ready(function()
{
$('th').hover(function()
{
$(this).find('.heading').show();
})
})
Related
I am trying to create an overlay that will cover an entire div/card. I have three cards that I want to rollover black when active. For some reason, I can't get the entire div to be selected.
HTML:
<div class="item ">
<div class="overlay">
<img src="http://placehold.it/600x350">
<h2>Title</h2>
<p> Text</p>
</div><div class="overlay"> </div>
</div>
and CSS:
.item {
padding: 0px 0;
margin: 1%;
border-radius: 2px;
flex: 1 250px;
height: auto;
text-align: center;
background: linear-gradient(0deg, #efefef, #ffffff);
}
.overlay {
position: relative;
background-color: rgba(0,0,0,0)
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.overlay:hover {
opacity: 1;
background-color: rgba(0,0,0,1);
}
CODEPEN EXAMPLE
div.item has a certain size and shape. Style it as relative so that the next thing will work
Make div.overlay position:absolute - that will overlay it, but it has no size, so it will still be invisible.
Then, make div.overlay the full height of its parent (div.item).
When made visible (at :hover) it will be 100% height/width of .item, and will overlay it.
body {background-color: #C70025;}
img {width: 100%;}
#container {width:90%;margin:0 auto;display:flex;flex-wrap:wrap;
justify-content:space-between;}
.item {color:#000;padding:0px 0;margin:1%;border-radius:2px;flex:1 250px;height:auto;text-align:center;background:linear-gradient(0deg, #efefef, #ffffff);}
.item{position:relative;}
.overlay {
position:absolute;
top:0;left:0;right:0;bottom:0;
background-color: rgba(0,0,0,0);
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.overlay:hover {
opacity: 1;
background-color: rgba(0,0,0,1);
}
<div id="container">
<div class="item ">
<img src="http://placehold.it/600x350">
<h2>Title</h2>
<p> Text</p>
<div class="overlay"> </div>
</div>
<div class="item">
<img src="http://placehold.it/600x350">
<h2> Title </h2>
<p>Text</p>
<div class="overlay"> </div>
</div>
<div class="item">
<img src="http://placehold.it/600x350">
<h2> Title </h2>
<p>Text</p>
<div class="overlay"> </div>
</div>
</div>
These images are using a CSS code for hovering effects, everything works good except i have no idea how to re arrange their position on the page.
Right now they are horizontally on top of each other, how can i make them side by side?:
body {
color:#000000;
background-color:#000000;
background-image:url('Background Image');
background-repeat:no-repeat;
}
a { color:#0000FF; }
a:visited { color:#800080; }
a:hover { color:#008000; }
a:active { color:#FF0000; }
#cf {
position:relative;
height:281px;
width:450px;
margin:0 auto;
}
#cf img {
position:absolute;
left:0;
-webkit-transition: opacity 200ms ease-in-out;
-moz-transition: opacity 200ms ease-in-out;
-o-transition: opacity 200ms ease-in-out;
transition: opacity 200ms ease-in-out;
}
#cf img.top:hover {
opacity:0;
}
<a href="http://example.com/page1">
<div id="cf">
<img class="bottom" src="images/img_a_1.jpg" />
<img class="top" src="images/img_a_2.jpg" />
</div></a>
<a href="http://example.com/page2">
<div id="cf">
<img class="bottom" src="images/img_b_1.jpg" />
<img class="top" src="images/img_b_2.jpg" />
</div></a>
<a href="http://example.com/page3">
<div id="cf">
<img class="bottom" src="images/img_c_1.jpg" />
<img class="top" src="images/img_c_2.jpg" />
</div></a>
As arhak has previously commented, we do not use an id more than once on a page, they must be unique. Here are the following changes:
Changed each #cf to class .cf.
Added display:table-cell to each .cf so that they are side-by-side.
Changed each .cf dimensions to something manageable 50 x 50px.
Replaced non-functioning <img> src to working values*.
Decreased the size of each .cf to 50 x 50px*.
All of these changes are optional with the exception of the first and second changes.
*I know that your relative urls work for you, but an example that doesn't work here will make things harder to demonstrate. In the future if you have images, use those or images of equivalent size in your examples. If we don't know that 50 x 50px is insufficient for your requirements, that will slowdown the process in finding a resolution.
SNIPPET
body {
color: #fff;
background-color: #000000;
background-image: url('Background Image');
background-repeat: no-repeat;
}
a {
color: #0000FF;
}
a:visited {
color: #800080;
}
a:hover {
color: #008000;
}
a:active {
color: #FF0000;
}
.cf {
position: relative;
height: 50px;
width: 50px;
margin: 0 auto;
display:table-cell;
}
.cf img {
position: absolute;
left: 0;
-webkit-transition: opacity 200ms ease-in-out;
-moz-transition: opacity 200ms ease-in-out;
-o-transition: opacity 200ms ease-in-out;
transition: opacity 200ms ease-in-out;
}
.cf img.top:hover {
opacity: 0;
}
<body>
<a href="http://example.com/page1">
<div class="cf">
<img class="bottom" src='http://placehold.it/50x50/00f/fff?text=1'>
<img class="top" src='http://placehold.it/50x50/cf0/000?text=2'>
</div>
</a>
<a href="http://example.com/page2">
<div class="cf">
<img class="bottom" src='http://placehold.it/50x50/0e0/110?text=3'>
<img class="top" src='http://placehold.it/50x50/0bb/011?text=4'>
</div>
</a>
<a href="http://example.com/page3">
<div class="cf">
<img class="bottom" src='http://placehold.it/50x50/fff/000?text=5'>
<img class='top' src='http://placehold.it/50x50/f00/fff?text=6'>
</div>
</a>
</body>
body {
color:#000000;
background-color:#000000;
background-image:url('Background Image');
background-repeat:no-repeat;
}
a { color:#0000FF; }
a:visited { color:#800080; }
a:hover { color:#008000; }
a:active { color:#FF0000; }
#cf img {
text-align: center;
}
#cf img.top:hover {
opacity:0;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<body>
<a href="http://example.com/page1">
<div class="col-xs-12 form-group" id="cf">
<img class="bottom col-xs-6" src="images/img_a_1.jpg" />
<img class="top col-xs-6" src="images/img_a_2.jpg" />
</div></a>
<a href="http://example.com/page2">
<div class="col-xs-12 form-group" id="cf">
<img class="bottom col-xs-6" src="images/img_b_1.jpg" />
<img class="top col-xs-6" src="images/img_b_2.jpg" />
</div></a>
<a href="http://example.com/page3">
<div class="col-xs-12 form-group" id="cf">
<img class="bottom col-xs-6" src="images/img_c_1.jpg" />
<img class="top col-xs-6" src="images/img_c_2.jpg" />
</div></a>
</body>
Im trying to on hover make text appear under these circles but when ever I try to add paragraphs they just make my circles go out of place.
This is what I'm trying to achieve
http://imgur.com/TZfpQIF
https://jsfiddle.net/u02e1mfe/
HTML
<div class="row">
<p><b>Works</b></p>
<div "row1">
<div class="round-button">
<div class="round-button-circle" class=".col-md-4">
Google
</div>
</div>
<div class="round-button">
<div class="round-button-circle" class=".col-md-4">
nn
</div>
</div>
<div class="round-button">
<div class="round-button-circle" class=".col-md-4">
nm
</div>
</div>
</div>
<div "row2">
<div class="round-button">
<div class="round-button-circle" class=".col-md-4">
nn
</div>
</div>
<div class="round-button">
<div class="round-button-circle" class=".col-md-4">
nff
</div>
</div>
<div class="round-button">
CSS
.row
{
height: 80%;
width: 100%;
text-align:center;
padding-top: 2%;
font-size: 25;
}
.round-button {
display:inline-block;
position: relative;
width:10%;
padding-top: 2%;
}
.round-button-circle {
height: 100px;
position:relative;
margin:0 auto;
border:2px solid #f0f0f0;
background: white no-repeat center center;
-moz-border-radius:100px;
-webkit-border-radius:100px;
border-radius: 100px;
width: 100px;
cursor:pointer;
-webkit-transition: all 0.2s ease-in;
-moz-transition: all 0.2s ease-in;
-ms-transition: all 0.2s ease-in;
-o-transition: all 0.2s ease-in;
transition: all 0.2s ease-in;
font-size: 0%;
}
.round-button-circle:hover {
background:#000000;
text-decoration-color: white;
font-size: 50%;
margin-bottom: 80%;
}
.round-button a{
display:block;
float:left;
width:100%;
padding-top:50%;
padding-bottom:50%;
line-height:1em;
margin-top:-0.5em;
text-align:center;
color:#e2eaf3;
font-family:Verdana;
font-size:1.2em;
font-weight:bold;
text-decoration:none;
}
They are close together in the fiddle but in my actual website they aren't like that so just ignore it. Im trying to make the text appear below the circle when you hover over it. Any ideas? New to CSS and HTML
Add these lines to .round-button a css
position: absolute;
bottom: -90px;
color: red;
(You can replace the color, is just for you to notice the change)
I want my website to have the same effect this website has: Trask Industries
When the upper right image is hovered the text appears and yellow covers the image.
This is the effect I am failing to recreate in CSS and Html, using headers and hover opacity. In my attempts the headers become opaque rather than standing out like on that site. I also don't know how to make the headers appear and disappear on hover.
Here is the jsfiddle of my attempt.
.content1:hover, .content2:hover, .content3:hover, .content4:hover, .content5:hover, .content6:hover {
color: black;
opacity: 0.30;
transition: .2s;
webkit-transition: .2s;
-webkit-transition: all 500ms ease;
}
You must wrap the h1 and h2 in a div, and you would animate that div in css.
I also added a same class for the contents.
Here is an updated fiddle:
http://jsfiddle.net/bzm6T/2/
Basically, this is the updated code:
Code:
.contents:hover > div {
color: black;
opacity: 1;
}
.contents div {
opacity: 0;
display: block;
width: 100%; height: 100%;
background: rgba(255,255,255,0.3);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
<div class="container">
<a href="articleF.html" class="contents content1">
<div>
<h1>The Low Stakes of Modern life</h1>
<h2>Default 1Default 1Default 1Default 1Default 1Default 1</h2>
</div>
</a>
<a href="articleA1.html" class="contents content2">
<div>
<h1>AARON SWARTZ</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleA2.html" class="contents content3">
<div>
<h1>JOBILLY BOOP</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleD.html" class="contents content4">
<div>
<h1>Content4</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleK1.html" class="contents content5">
<div>
<h1>Content5</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleK1.html" class="contents Content6">
<div>
<h1>Content6</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
</div>
A slightly different approach, but basically the same with CSS transition: FIDDLE
.holder {
width: auto;
margin: 10px auto;
border: 1px solid black;
overflow: hidden;
}
.leftdiv {
float: left;
background-color: blue;
height: 100%;
color: white;
}
.picdiv {
float: right;
background-color: orange;
}
.picdiv img {
opacity: 1;
transition: opacity 1s ease-in-out;
}
.picdiv img:hover {
opacity: 0;
}
I'm trying to figure out how to give a semi-transparent image overlay (that appears on :hover) a CSS3 transition (ease). But it's not working. I'm not sure if it's because I'm missing something, or if transitions just don't work with the display property. Any ideas for a CSS workaround (I don't know JavaScript)? Thanks in advance.
Relevant HTML and CSS:
<div class="thumbnail">
<figure>
<img src="images/dude.jpg" alt=""/>
</figure>
<div class="thumbnail-overlay">
<h2>Project Name</h2>
<h3> Skills Skills Skills</h3>
<p>This is a project description.</p>
</div>
</div>
.thumbnail {
position:relative;
float:left;
width:40%;
margin:1.5% 1.5% 0 0;
}
.thumbnail-overlay {
background-color: #dark-gray;
display:none;
opacity:.9;
position:absolute;
top:0;
left:0;
width:100%; height:100%;
overflow:hidden;
-webkit-transition:all .3s ease;
-moz-transition:all .3s ease;
transition:all.3s ease;
}
.thumbnail:hover .thumbnail-overlay {
display:block;
}
as i see it is because display property. css transition doesn't work good with it and that's why you have this probleme.
here is the css code that i tested and work's ok:
.thumbnail .thumbnail-overlay {
background-color: #dark-gray;
display:block;
opacity:0;
position:absolute;
top:0;
left:0;
width:100%; height:100%;
overflow:hidden;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.thumbnail:hover .thumbnail-overlay {
opacity: .9;
}
hope it helps !!!
It is working for me.I seperated the CSS to another file and linked it to the HTML file.It works nice for me
HTML
<head>
<link rel="stylesheet" type="text/css" href="test.css">
</head>
<div class="thumbnail">
<figure>
<img src="/home/qbadmin/Downloads/Pic.jpg" alt=""/>
</figure>
<div class="thumbnail-overlay">
<h2>Project Name</h2>
<h3> Skills Skills Skills</h3>
<p>This is a project description.</p>
</div>
</div>
CSS
.thumbnail {
position:absolute;
float:left;
width:40%;
left :100 px;
top :100px;
margin:1.5% 1.5% 0 0;
}
.thumbnail-overlay {
background-color: #dark-gray;
display:none;
opacity:.9;
position:absolute;
top:100px;
left:100px;
width:100%; height:100%;
overflow:hidden;
-webkit-transition:all .3s ease;
-moz-transition:all .3s ease;
transition:all.3s ease;
}
.thumbnail:hover .thumbnail-overlay {
display:block;
opacity: .9;
}