Icon Hover effect made with divs, Margin Issue - html

Here's my Fiddle:
#facebookIcon{
vertical-align:middle;
color:white;
font-size:5.5em;
opacity:0.4;
}
#facebookinner:hover #facebookIcon{
opacity:1.0;
}
#facebookinner{
background:#3b5998;
border-radius:100px;
height:100px;
width:100px;
margin:0 auto;
text-align:center;
line-height:100px;
opacity:0.4;
-webkit-transition:
}
#facebookinner:hover{
opacity:1.0;
}
#facebookouter {
background-color:Green;
border:5px solid rgba(0,0,0,0);
height:100px;
width:100px;
border-radius:100px;
display: table-cell;
vertical-align: middle;
-webkit-transition: height 0.2s linear, width 0.2s linear,border 0.2s ease-out,border- radius 0.2s linear,margin 0.2s linear;
transition: height 0.2s linear, width 0.2s linear,border 0.2s ease-out,border-radius 0.2s linear,margin 0.2s linear;
-moz-transition: height 0.2s linear, width 0.2s linear,border 0.2s ease-out,border-radius 0.2s linear,margin 0.2s linear;
}
#facebookouter:hover {
height:130px;
width:130px;
border-radius:130px;
border:5px solid #3b5998;
opacity:1.0;
-webkit-transition: height 0.2s linear, width 0.2s linear,border 0.2s ease- out,border-radius 0.2s linear,margin 0.2s linear;
transition: height 0.2s linear, width 0.2s linear,border 0.2s ease-out,border-radius 0.2s linear,margin 0.2s linear;
-moz-transition: height 0.2s linear, width 0.2s linear,border 0.2s ease-out,border-radius 0.2s linear,margin 0.2s linear;
}
footer {
margin-top:250px;
height:150px;
position: absolute;
right: 0;
bottom: 10;
left: 0;
padding: 5 rem;
background-color: Green;
text-align: center;
padding-top:30px;
padding-left:40px;
}
/*________________Here is the Second Icon________________*/
#twitterIcon{
vertical-align:middle;
color:white;
font-size:3.5em;
-webkit-transition:font-size 0.2s;
-moz-transition:font-size 0.2s;
transition:font-size 0.2s;
}
#twitterinner:hover #twitterIcon{
opacity:1.0;
font-size: 3.5 em
}
#twitterinner {
background:#23dcd5;
border-radius:100px;
height:100px;
width:100px;
margin:0 auto;
text-align:center;
line-height:100px;
-webkit-transition:height 0.2s, width 0.2s, line-height 0.2s;
-moz-transition:height 0.2s, width 0.2s, line-height 0.2s;
transition:height 0.2s, width 0.2s, line-height 0.2s;
}
#twitterinner:hover{
opacity:1.0;
height: 80px;
width:80px;
line-height:80px;
}
#twitterouter{
background-color:Green;
border:5px solid #23dcd5;
height:100px;
width:100px;
border-radius:100px;
display: table-cell;
vertical-align: middle;
opacity:0.7;
}
#twitterouter:hover {
opacity:1.0;
}
I`m a beginner in CSS (1 week of learning) and I saw this hover effect (at the bottom of this page for the Social Icons).
So I tried to make the same hover effect with my limited skills. After a long time I made the same effect with two divs and an Icon.
The Problem is now that:
Im not able to set a margin to any of the "Icons", this means i want a gap between the FacebookIcon and the TwitterIcon so they wont interfere like the FacebookIcon is interfering with the Twitter Icon.
How can I hover over the inner div and activating the hover of the outer div (I can not make the inner div the parent of the outer because the outer has to be bigger than the inner).
I want the FacebookIcon Outer to grow from the center and not like its doing now. (Like in the example in the Webpage mentioned above.
I've searched for this solutions long time and found nothing suitable. Probably there is a much easier way of creating this Icons, this would be another solution :)
Thanks for your advice and sorry for my bad English (German here).

Im not able to set a margin to any of the "Icons"
That's because margin property is not applicable to display: table-cell elements.
How can I hover over the inner div and activating the hover of the
outer div
Well, you need to change your strategy. Set all the necessary CSS declarations on the child (<i> tag) and change the styles on parent:hover i selector.
Here we go:
HTML:
<footer>
<a href="#" class="icon-wrapper">
<i class="icon icon-facebook"></i>
</a>
<a href="#" class="icon-wrapper">
<i class="icon icon-twitter"></i>
</a>
</footer>
CSS:
.icon-wrapper {
float: left;
display: block;
margin: 0 1.875rem;
color: white;
font-size: 5.5rem;
}
.icon-wrapper i.icon {
display: block;
width: 8rem;
height: 8rem;
line-height: 8rem;
border-radius: 50%;
opacity: 0.5;
transition: all .2s;
}
.icon-wrapper:hover i.icon {
opacity: 1;
box-shadow: 0 0 0 1.5625rem green, /* <-- = the parent's background-color */
0 0 0 1.875rem #9b59b6;
}
.icon-facebook {
background-color: #3b5998;
}
.icon-twitter {
background-color: #23dcd5;
}
WORKING DEMO.

Related

Divs move downwards when padding expands on hover

I have two divs, when one hovers over the text (which are links) of a div, the padding increases from 0 to 5px. My issue is that whenever I hover over the text and the padding increases, the divs move down. Here's the code:
<div id="container" class="text1">
<a id="text1style" href="#" style="font-family:arial;font-size:120%;
text-decoration:none;">Some text</a>
</div>
<div id="container" class="text2">
<a id="text2style" href="#" style="font-family:arial;font-size:120%;
text-decoration:none;">text</a>
</div>
#container {
position:relative;
}
a:link, a:visited, a:active {
color:blue;
}
a:hover {
color:yellow;
}
.text1box {
left:200px;
bottom:35px;
width:243px;
}
#text1style {
-webkit-transition:color 0.5s;
-o-transition:color 0.5s;
-moz-transition:color 0.5s;
-ms-transition:color 0.5s;
transition:color 0.5s;
-webkit-transition:background-color 0.5s;
-o-transition:background-color 0.5s;
-moz-transition:background-color 0.5s;
-ms-transition:background-color 0.5s;
transition:background-color 0.5s;
}
#text1style:hover {
padding:5px;
border-radius:10px;
background-color:red;
}
.text2 {
left:455px;
bottom:57px;
width:90px;
}
#text2style {
-webkit-transition:color 0.5s;
-o-transition:color 0.5s;
-moz-transition:color 0.5s;
-ms-transition:color 0.5s;
transition:color 0.5s;
-webkit-transition:background-color 0.5s;
-o-transition:background-color 0.5s;
-moz-transition:background-color 0.5s;
-ms-transition:background-color 0.5s;
transition:background-color 0.5s;
}
#text2style:hover {
padding:5px;
border-radius:10px;
background-color:red;
}
Updated code: I have applied the padding expansion to the individual links, instead of the div, and this has helped out. I still have two issues: 1) The texts (of links) still shift slightly to the right. 2) When I remove the mouse (i.e: hover ends) you can see that the text has lost padding and border radius as the background (red) fades away.
How could I resolve these two issues? Many thanks.
You can do that by moving the 2 boxes upward to compensate for the padding moving them downward.
And id should be unique
.container {
position: relative;
-webkit-transition: color 0.5s;
-o-transition: color 0.5s;
-moz-transition: color 0.5s;
-ms-transition: color 0.5s;
transition: color 0.5s;
-webkit-transition: background-color 0.5s;
-o-transition: background-color 0.5s;
-moz-transition: background-color 0.5s;
-ms-transition: background-color 0.5s;
transition: background-color 0.5s;
background-color: red;
text-align: center;
}
.box1 {
left: 200px;
/*bottom: 35px;*/
width: 221px;
border-radius: 10px;
}
.box2 {
left: 455px;
/*bottom: 57px;*/
width: 66px;
border-radius: 10px;
}
a:link,
a:visited,
a:active {
color: blue;
}
a:hover {
color: yellow;
}
.container:hover {
top: -5px;
padding: 5px 0;
background-color: dodgerblue;
}
.container.box1:hover + .box2 {
top: -10px;
}
<div id="container1" class="container box1">
<a href="#" style="font-size:120%;
text-decoration:none;">Some text</a>
</div>
<div id="container2" class="container box2">
<a href="#" style="font-size:120%;
text-decoration:none;">text</a>
</div>
Based on question edit, updated with a 2:nd sample, where I added padding: 0 5px to the a:link rule to compensate for the hovered padding
#container1, #container2 {
position: relative;
}
a:link,
a:visited,
a:active {
color: blue;
padding: 0 5px;
}
a:hover {
color: yellow;
}
.text1box {
left: 200px;
bottom: 35px;
width: 243px;
}
#text1style {
-webkit-transition: color 0.5s;
-o-transition: color 0.5s;
-moz-transition: color 0.5s;
-ms-transition: color 0.5s;
transition: color 0.5s;
-webkit-transition: background-color 0.5s;
-o-transition: background-color 0.5s;
-moz-transition: background-color 0.5s;
-ms-transition: background-color 0.5s;
transition: background-color 0.5s;
}
#text1style:hover {
padding: 5px;
border-radius: 10px;
background-color: red;
}
.text2 {
left: 455px;
bottom: 57px;
width: 90px;
}
#text2style {
-webkit-transition: color 0.5s;
-o-transition: color 0.5s;
-moz-transition: color 0.5s;
-ms-transition: color 0.5s;
transition: color 0.5s;
-webkit-transition: background-color 0.5s;
-o-transition: background-color 0.5s;
-moz-transition: background-color 0.5s;
-ms-transition: background-color 0.5s;
transition: background-color 0.5s;
}
#text2style:hover {
padding: 5px;
border-radius: 10px;
background-color: red;
}
<div id="container1" class="text1">
<a id="text1style" href="#" style="font-family:arial;font-size:120%;
text-decoration:none;">Some text</a>
</div>
<div id="container2" class="text2">
<a id="text2style" href="#" style="font-family:arial;font-size:120%;
text-decoration:none;">text</a>
</div>
I created a jsfiddle for you:
https://jsfiddle.net/squeLsa6/
<div id="" class="box1 container">
Some text
</div>
<div id="" class="box2 container">
text
</div>
<style type="text/css">
.container {
position:relative;
-webkit-transition:color 0.5s;
-o-transition:color 0.5s;
-moz-transition:color 0.5s;
-ms-transition:color 0.5s;
transition:color 0.5s;
-webkit-transition:background-color 0.5s;
-o-transition:background-color 0.5s;
-moz-transition:background-color 0.5s;
-ms-transition:background-color 0.5s;
transition:background-color 0.5s;
padding:5px;
}
a:link, a:visited, a:active {
color:blue;
padding:5px;
}
a:hover {
color:yellow;
padding:5px;
}
.box1 {
left:200px;
bottom:35px;
width:221px;
border-radius:10px;
}
.box2 {
left:455px;
bottom:57px;
width:66px;
border-radius:10px;
}
.container:hover {
background-color:dodgerblue;
}
</style>
Basically I moved the padding from the hover state to the a's and the container. I also converted container to be a class, because id's should be unique. I'm not sure exactly how you want it to work, so you may need to play with it a little, but this should get you started.
First of all, you confused the id with classes. I changed the name ID with CLASS and it works; In the Css the classes have "." and IDs have "#", be aware of this. When i hover on the div it take a padding of 5px and it is natural that the other div lightly move due to the padding.
If you don't want to move the box you have to give padding anywhere apart of padding-bottom.

Tumblr footers - Making them balanced?

I am currently working on my tumblr theme footer size. I changed the paddings of the ".post .footer" so that it would be smaller and came up with:
#wrapper #content .post .footer {
background: {color:Footer} url({image:footer});
{block:IfFooterBorder}
border: {text:Footer Border}px solid {color:Footer Border};
{/block:IfFooterBorder}
font-family: {text:font family secondary};
font-size: 9px;
color: {color:Footer text};
padding:4px 8px;
margin-top:15px;margin-bottom:8px;
line-height:8px; z-index:10;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
#wrapper #content .post .footer .date {
width: 67%;
float: left;
}
#wrapper #content .post .footer .notes {
width: 33%;
float: right;
text-align: right;
}
#wrapper #content .post .footer .notes a, #wrapper #content .post .footer .date a {
color: {color:Footer link};
text-decoration:none;
}
#wrapper #content .post .footer .tags a {
color: {color:Footer link};
{block:ifnotlinkunderline}
text-decoration: none;
{/block:ifnotlinkunderline}
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
font-size: 10px;
}
So then I tested it and am satisfied with the size. But then i noticed that the second footer (footer for the post tags)'s size is slightly bigger than the first footer (the footer for the time or date and notes).
So then i decided to edit it and add a separate section for the "tags" footer. I placed this in between ".post .footer .notes a,.post .footer .date a" and " .post .footer .tags a":
#wrapper #content .post .footer .tags {
padding:0px 0px;
}
I put in 0px paddings so that the size would be smaller as there are no paddings. But it still did not work so i changed the paddings to:
#wrapper #content .post .footer .tags {
padding:-1px -1px;
}
Then i tested it, but it still did not work. What's going on? The second footer's size is still bigger and the footers are still imbalanced. Am I missing something here?
Okay, tag is an inline element by default, so you need to add display:block; to it so that it can adapt to your custom width and height.
#wrapper #content .post .footer .tags a {
color: #ffdaf4;
text-decoration: none;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
font-size: 10px;
font-style: italic;
cursor: help;
display: block; //add this line to change the height
line-height: 8px; // add this line to vertical center your text for better looking
}

CSS transition property is not working properly

I am trying to add transition property using css which is not working properly, I am giving my html & css code below :
HTML :
<ul class="job-tile">
<li style="background-color:#000" class="active" id="sw_start">Tile 1</li>
<li style="background-color:#000" class="active" id="sw_start">Tile 1</li>
</ul>
CSS :
.job-tile
{
position:relative;
list-style:none;
text-align:center;
display:block;
float:left;
}
.job-tile li
{
color: #FFFFFF;
display: inline-block;
font-size: 18px;
height: 22px;
margin: 12px;
padding: 50px 0;
position: relative;
width: 200px;
font-weight:normal;
cursor:pointer;
float:left;
opacity:0.6;
filter:alpha(opacity=60);
border-radius: 3px;
transition: background-color 0.2s linear 0s, color 0.2s linear 0s;
}
.job-tile li:hover
{
opacity:1 !important;
filter:alpha(opacity=100) !important;
transition: background-color 0.2s linear 0s, color 0.2s linear 0s;
}
If I put a background color on hover property, it will works fine, but I want to place opacity in on hover.any idea?
I am also giving working js fiddle link :- http://jsfiddle.net/4Qcr3/1/
The transition-property you set is not enough (missing the opacity property), you should use the all keyword instead. Also the transition is not fully implemented by all browsers, you should add vendor prefixes to make it function cross-browser well:
.job-tile li {
...
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.job-tile li:hover {
opacity:1 !important;
filter:alpha(opacity=100) !important;
}
Here is the working fiddle

Make image or div slide up or down when hovering parent div

I currently have this JSfiddle.
HTML:
<div class="refTable">
<div class="refRow">
<div class="refCell"><img src="images/test.jpg" /><p>Test 1</p></div>
<div class="refSep"></div>
<div class="refCell"><img src="images/test.jpg" /><p>Test 2</p></div>
<div class="refSep"></div>
<div class="refCell"><img src="images/test.jpg" /><p>Test 3</p></div>
</div>
</div>
CSS:
.refTable {
display:table;
max-width:919px;
width:100%;
margin:0px auto;
}
.refRow {
display:table-row;
}
.refCell {
display:table-cell;
width:291px;
text-align: center;
font-size:16px;
border:1px #ffffff solid;
padding:0px 0px 10px 0px;
background:#eaeaea;
color:#333333;
-webkit-border-radius: 20px 20px 20px 20px;
border-radius: 20px 20px 20px 20px;
resize: none;
outline:0;
transition-duration: 0.2s;
}
.refCell img {
-webkit-border-radius: 20px 20px 0px 0px;
border-radius: 20px 20px 0px 0px;
padding-bottom:5px;
}
.refCell p {
line-height: 20px;
}
.refCell:hover {
border-color:#b32f01;
background:#ffffff;
-webkit-transition: color background 0.2s ease-in-out;
-moz-transition: color background 0.2s ease-in-out;
-ms-transition: color background -0.8s ease-in-out;
-o-transition: color background 0.2s ease-in-out;
transition: color background 0.2s ease-in-out;
cursor:pointer;
color:#cacaca;
}
.refCell:hover img {
opacity:0.4;
-webkit-transition: opacity 0.2s ease-in-out;
-moz-transition: opacity 0.2s ease-in-out;
-ms-transition: opacity -0.8s ease-in-out;
-o-transition: opacity 0.2s ease-in-out;
transition: opacity 0.2s ease-in-out;
}
.refSep {
display:table-cell;
width:20px;
}
In the fiddle, no images display in the boxes. However, there normally would be. On hover, the boxes change background color, font color, and, provided there is an image, image opacity. That's fine.
Now, I would like to make it so that, on hover, an image or div "slides" up from the bottom/side/top that says "Visit this website", possibly with some sort of icon.
What is the best approach? I've really been thinking about it, but I can't come up with a solution.
I did this with just css :hover and css3 transitions.
This is the css I wrote,
.info {
position: absolute;
top: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.4);
text-align: center;
-webkit-transition: top 0.6s ease-in-out;
left: 0;
color: #f7f7f7;
text-decoration: none;
}
.refCell:hover .info {
top: 0;
display: block;
}
I also added this to the .refCell class,
position: relative;
overflow: hidden;
The html I added,
<span class="info">Click to view website</span>
Here is the JSFIDDLE to see how it works.

CSS - tooltip only with css and html doesn't work

I am trying to do simple tooltip only with css3 and html, but the transition doesn't work. What am I doing wrong?
HTML
<p>
This has tooltip
</p>
<div class="tooltip">Tooltip content</div>
CSS
p {
width: 200px;
background-color: aqua;
padding: 10px;
margin-top: 50px;
}
div.tooltip {
position: absolute;
width: auto;
padding: 10px;
background-color: rgba(0,0,0, 0.5);
top: 0px;
display: none;
opacity: 0.0;
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
p:hover + div.tooltip {
display: block;
opacity: 1.0;
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
http://jsfiddle.net/MCDg4/
Update / Alternate solution
For a modern browser CSS3 solution you could use pseudo elements..
<span data-tooltip="I am the tooltip">This has a tooltip</span>
and
[data-tooltip]{
position:relative;
}
[data-tooltip]:before{
content:attr(data-tooltip);
position:absolute;
bottom:110%;
padding:10px;
background:#666;
opacity:0;
color:white;
font-size:smaller;
-webkit-transition:opacity 1s ease;
-o-transition:opacity 1s ease;
transition:opacity 1s ease;
pointer-events:none;
}
[data-tooltip]:hover:before{
opacity:1;
}
Demo at http://jsfiddle.net/BJ2tr/
(this could be done without pseudo-elements by nesting the tooltip inside the elements that it refers to, and adjusting the css accordingly)
Unfortunately when you change display from none to something else, you cannot have transitions.
Instead of display:none you could just offset it outside of the window (with top:-9999px) and bring it to position when showing it.
div.tooltip {
position: absolute;
width: auto;
padding: 10px;
background-color: rgba(0,0,0, 0.5);
top: -999px; /*CHANGED THIS AND REMOVED display:none*/
display: none;
opacity: 0.0;
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
p:hover + div.tooltip {
opacity: 1.0;
top: 0px; /*ADDED THIS AND REMOVED display:block*/
transition: opacity 1s;
-webkit-transition: opacity 1s;
-o-transition: opacity 1s;
-moz-transition: opacity 1s;
}
This will, however, not fade out (only in) since it moves it away on mouseout (so it actually does fade but you do not see it because it is outside the viewport)..
Explanation
You put transition only on opacity, while when changing to display:block; it is shown as a block with opacity:1; by default.
Solution
(JSFiddle)
Delete the display:none; and display:block on your tooltip element.