transition with css3 - html

Does anybody know how to algin a line under my text automatically to all?
here is my animation
<div class="line"><div>behance.net</div>
</div>
<br>
<div class="line"><div>google.pl</div>
</div>
<br>
<div class="line"><div>twitter.com</div>
</div></br>
CSS
.line{
font-family:Tahoma;
width:0px;
position: absolute;
background:black;
transition:width 0.4s ease ;
}
div:hover{
position: absolute;
width:86px;
}
.line div{
background:#fff;
position:relative;
bottom:1px;
}
In the first example, everything works fine, the width of line is ok, but in other no.

You can try this - DEMO
HTML
<div class="line">behance.net <span></span></div> <br />
<div class="line">google.pl <span></span></div> <br />
<div class="line">twitter.com <span></span></div> <br />
CSS
.line {
font: 400 1em Tahoma;
margin: 5px;
display: inline-block;
overflow: hidden;
padding: 2px 0;
position: relative;
}
.line span {
display: block;
position: absolute;
left: -90px;
bottom: 1px;
height: 1px;
width: 100%;
background: #c00;
-webkit-transition: all .4s;
}
.line:hover span {
left: 0;
}

Another solution with less markup:
demo
<div class='line'>behance.net</div><br>
<div class='line'>google.pl</div><br>
<div class='line'>twitter.com</div><br>
CSS:
.line {
display: inline-block;
position: relative;
background-position: -85px 0;
transition: 1s;
cursor: pointer;
}
.line:before {
position: absolute;
right: 0; top: 0; bottom: 0; left: 0;
background: linear-gradient(0deg, crimson 1px, transparent 1px) no-repeat;
background-position: inherit;
background-size: 100% 100%;
color: transparent;
content: '';
}
.line:hover { background-position: 0 0; }
Note:
My demo uses -prefix-free which adds prefixes as needed. WebKit browsers still need prefixes for transitions and gradients. You'll have to add these yourself in your code. When you do, please remember to always put the unprefixed ones last!

Related

Rounding background image of button

I'm required to have a rounded "growing" effect upon hovering over a button.
Please see this link for a reference of how I need the button to work.
http://demo1.wpopal.com/corpec/home-4/
Currently I have achieved the "Not this" effect upon hover; though my employer wants the effect to have that bit of rounding.
I used the following css on the "not this" button to achieve the growing effect, though i need the edges to be rounded.
.Custom-Button a {
position: relative;
display: inline-block;
padding: 15px 70px;
border: 1px solid #fdc900 !important;
color: white;
font-size: 30px;
font-family: arial;
background-image: linear-gradient(#fdc900, #fdc900);
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: 0% 100%;
transition: background-size .5s, color .5s;
}
.Custom-Button a:hover {
background-size: 100% 100%;
color: black;
}
<div class="Custom-Button">
BUTTON
</div>
I'm only allowed to use CSS to achieve the following effect and have already spent a day trying to get this to work.
applying pseudo element for button solve it ! hope this help!
.Custom-Button{
position: relative;
display: inline-block;
padding: 15px 70px;
border: 1px solid #fdc900 !important;
color: white;
font-size: 30px;
font-family: arial;
border-radius:50px;
position:relative;
}
.Custom-Button a{
z-index:99;
text-decoration:none;
transition:color 1s;
}
.Custom-Button:hover:after{
width:100%;
}
.Custom-Button:hover a{
color:black;
}
.Custom-Button:after{
width:0%;
transition: width 1s;
height:100%;
z-index:-1;
content:"";
position:absolute;
border-radius:50px;
top:0;
left:50%;
transform:translateX(-50%);
background-image: linear-gradient(#fdc900, #fdc900);
}
<div class="Custom-Button">
BUTTON
</div>
You can achieve this effect, by combining z-index, and transitions of position and width of an underlying element:
When hovering, the child of the filler, will transition from
position: absolute; left: 50%;
to
position: absolute; left: 0;
while also resizing from width: 0; to width: 100%;
This is what will give you the desired effekt of "growing from the middle"
also you need to apply a border radius to your growing element
a {
position: relative;
display: inline-block;
padding: 15px 70px;
border: 1px solid #fdc900 !important;
color: black;
font-size: 30px;
font-family: arial;
border-radius: 32px;
}
.text {
position: relative;
z-index: 2000;
}
.filler {
position: absolute;
z-index: 1000;
top: 0;
left: 50%;
width: 0;
height: 100%;
border-radius: 32px;
/* half of <a> height */
background-color: #fdc900;
transition: width .5s, color .5s, left .5s;
}
a:hover .filler {
z-index: 500;
width: 100%;
left: 0;
color: black;
}
a:hover .text {
color: white;
}
<a href="#">
<div class="text">
BUTTON
</div>
<div class="filler">
</div>
</a>

Css translate y making background-image disappear

I am having a problem with an element when I use the translate-y in active state, it makes the background-image disappear. Click the element and you will see the image disappear.
The Css:
.glyphsblock i {
display: inline-block;
position: relative;
width: 38px;
height: 38px;
background-size: contain;
background-repeat: no-repeat;
background-position: center, center;
border: 1px solid #fff;
margin: 1px;
flex-shrink: 0;
cursor: pointer;
transition: all ease 0.1s;
}
.glyphsblock i:before {
background: radial-gradient(#8ed3c8, #224945);
content: " ";
width: 100%;
height: 100%;
position: absolute;
z-index: -1;
top: 0;
left: 0;
}
.glyphsblock i:active {
transform: translateY(2px);
}
.glyph-A {
background-image: url(https://atlasdatabase.github.io/glyphs/a.png);
}
HTML Code:
<div class="glyphsblock">
<i class="glyph-A"></i>
</div>
Also a jsfiddle of the issue: https://jsfiddle.net/go0tbb53/
Refactor your CSS to remove the negative z-index, which can produce unpredictable results. This is what was causing the transform to glitch and hide the glyph icon.
I've adjusted your snippet so now the i itself has the radial gradient, and the ::before pseudo-element is laying the glyph graphic on top of it.
You can see it working below:
.glyphsblock i {
background: radial-gradient(#8ed3c8, #224945);
display: inline-block;
position: relative;
width: 38px;
height: 38px;
border: 1px solid #fff;
margin: 1px;
flex-shrink: 0;
cursor: pointer;
transition: all ease 0.1s;
}
.glyphsblock i::before {
background-size: contain;
background-repeat: no-repeat;
background-position: center, center;
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.glyphsblock i:active {
transform: translateY(2px);
}
.glyph-A::before {
background-image: url(https://atlasdatabase.github.io/glyphs/a.png);
}
<div class="glyphsblock">
<i class="glyph-A"></i>
</div>
This may not be totally conventional, but I changed your jsfiddle to use a sized div for the background and an image for the icon itself. If you want to use multiple icons, simply make a larger wrapper div for multiple of what is currently called glyphsblock.
Also, my solution doesn't have any javascript, which is helpful :)
.bg-grad {
background: radial-gradient(#8ed3c8, #224945);
width: 38px;
height: 38px;
z-index: -1;
position: absolute;
}
.glyphsblock:active {
transform: translateY(2px);
cursor: pointer;
transition: all ease 0.1s;
}
<div class="glyphsblock">
<div class="bg-grad">
</div>
<img src="https://atlasdatabase.github.io/glyphs/a.png" height=38px width=38px/>
</div>

How to write Text on a image.

How to add TEXT in the image...so that the TEXT is view-able only when the image becomes dark when mouse is placed over it.. something like ..the one given in the example image below...
Thanks for your help.
.image {
width: 250px;
height: 200px;
background: black;
position: relative;
overflow: hidden;
}
.image img {
transition: all ease 1s;
}
.image:hover img { /* Darkening effect on mouseover */
background: black;
opacity: 0.7;
}
.image .arrow { /* Creates a half triangle with top and left arrow transparent */
opacity: 0;
border-color: transparent #f2f2f2 #f2f2f2 transparent;
transition: all ease 1s;
position: relative;
}
.image:hover .arrow { /* Mouseover effect */
opacity: 1;
font-family: Roboto;
font-size: 36px;
text-align: center;
border-image: none;
border-style: solid;
border-width: 45px;
position: absolute;
bottom: 0;
font-weight: normal;
width: 0;
height: 0;
right: 0;
}
.image:hover .arrow {
border-image: none;
border-style: solid;
border-width: 45px;
bottom: 0;
display: block;
font-family: Roboto;
font-size: 36px;
font-weight: normal;
height: 0;
opacity: 1;
position: absolute;
right: 0;
text-align: center;
width: 0;
}
.image .arrow {
border-color: transparent #f2f2f2 #f2f2f2 transparent;
opacity: 0;
position: relative;
transition: all 1s ease 0s;
}
.image .arrow span {
left: 5px;
position: relative;
top: -10px;
}
<div class="image">
<img src="http://lorempixel.com/250/200/sports" />
<div class="arrow"><span>></span></div>
</div>
enter image description here
It's simple. Create some text inside your wrapper div, then order the text to display on hovering the wrapper. Below is a demo of this logic.
The HTML:
<div class="image">
<p>I'm some very interesting text!</p>
<div class="arrow"><span>></span></div>
</div>
The CSS:
p{
color: #fff;
opacity: 0;
font-weight: bold;
text-align: center;
font-size:32px;
color: red;
/* bring your own prefixes */
transform: translate(0, 50%);
transition: all .5 ease;
}
.image:hover p {
visibility: visible;
opacity: 1;
}
CODEPEN DEMO
i think you can create like this
you need to change the position of the .image class so that text div can appear overlap on that
.image-hover-wrapper {
display:none;
text-align: center;
width: 250px;
color: red;
font-size: 35px;
position: relative;
top: -125px;
background: rgba(255,255,255,0.6);
}
.image:hover > .image-hover-wrapper{
display:block;
opacity:0.8;
transition-property: animation;
transition-duration: 2s;
transition-timing-function: linear;
}
<div class="image">
<img src="http://lorempixel.com/250/200/sports" />
<div class="arrow"><span></span></div>
<div class="image-hover-wrapper">
Hii
</div>
</div>
and here is the
Updated DEmo

Show the Background-Color of a DIV with a lower z-index

I want to make a part of a DIV (div2) transparent so it shows the background-color of a DIV (div1) that is under the DIV (div2).
http://jsfiddle.net/499nhjb0/2/
<br>
<div class="firstDiv" style="z-index:1;" >
<img src="http://fs1.directupload.net/images/150226/fag7h2u7.png" style="display:block;" width="auto" height="50"/>
</div>
<div class="secondDiv" style="z-index:2; ">
<img src="http://fs2.directupload.net/images/150226/xmv678we.png" style="display:block;" width="auto" height="50"/>
</div>
<br>
div1 with higher z-index
<br>
<div class="firstDiv" style="z-index:3;" >
<img src="http://fs1.directupload.net/images/150226/fag7h2u7.png" style="display:block;" width="auto" height="50"/>
</div>
<div class="secondDiv" style="z-index:2; ">
<img src="http://fs2.directupload.net/images/150226/xmv678we.png" style="display:block;" width="auto" height="50"/>
</div>
<br>
The images i use are transparent so the color (div-background) is variable. Currently the peak of image1 looks like its not from image1.
I want that it looks like this:
I have created two types of images you can see in the fiddle.
Do you have an idea how to solve the problem? I can change the transparency images if you have an idea. The images can be different.
You really don't need images here, you can use a css 100% solution with css triangle:
.arrow {
width:100px;
height:50px;
background-color: red;
position: relative;
float: left;
}
.arrow:before,
.arrow:after{
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 25px 0 25px 50px;
position: absolute;
top: 0;
}
.arrow:before {
left:0;
border-color: transparent transparent transparent #fff;
}
.arrow:after {
right:-50px;
}
.arrow-left {
z-index:1;
background-color: red;
}
.arrow-left:after {
border-color: transparent transparent transparent red;
}
.arrow-right {
margin-left: 10px;
background-color: blue;
}
.arrow-right:after {
border-color: transparent transparent transparent blue;
}
<div class="arrow arrow-left"></div>
<div class="arrow arrow-right"></div>
Here is a workable exemple, with over effect and active state : http://jsfiddle.net/jo27axjc/1/
Have Fun !
.breadcrumb {
display: inline-block;
overflow: hidden;
}
.breadcrumb a {
text-decoration: none;
outline: none;
display: block;
float: left;
font-size: 12px;
line-height: 36px;
color: white;
padding: 0 20px 0 10px;
background: blue;
position: relative;
}
.breadcrumb a:first-child:before {
left: 14px;
}
.breadcrumb a:last-child {
border-radius: 0 5px 5px 0;
}
.breadcrumb a.active, .breadcrumb a:hover span, .breadcrumb a:hover{
background: red;
}
.breadcrumb a.active:after, .breadcrumb a:hover:after {
background: red;
}
.breadcrumb a span{
display: block;
z-index: 2;
position: relative;
left: 20px;
background: blue;
padding-right: 5px;
}
.breadcrumb a.active{
padding-left:0;
}
.breadcrumb a.active span{
background:red;
}
.breadcrumb a:after {
content: '';
position: absolute;
top: 0;
right: -18px;
width: 36px;
height: 36px;
transform: scale(0.707) rotate(45deg);
z-index: 1;
background:blue;
box-shadow:
2px -2px 0 2px rgba(255, 255, 255, 1),
3px -3px 0 2px rgba(255, 255, 255, 0.1);
}
.breadcrumb a:last-child:after {
content: none;
box-shadow:none;
}
I find a new solution, but not easy to implement. First you need a calculator and know how Math Pythagore is working.
The idea is to have a box with background image and the same image on child, then place the child image at the right then rotate, the difficult part are to place exactly the image to correspond with the background image.
For the separator, i used a rotated square placed between the two arrow.
Then for the last arrow, i used the same way to the first arrow without the before triangle to hide the first part.
All placed in absolute with z-index.
But finally working with images. Enjoy!
.wrap {
position: relative;
height: 100px;
overflow: hidden;
}
.arrow {
position: absolute;
width: 136px;
height: 100px;
}
.arrow-left:before {
content: "";
position:absolute;
top: 0;
left:0;
width: 0;
height: 0;
border-style: solid;
border-width: 50px 0 50px 50px;
border-color: transparent transparent transparent #ffffff;
}
.arrow span {
width:70.71px;
height:70.71px;
overflow: hidden;
transform: rotate(45deg);
position: absolute;
top: 14px;
right: -35px;
}
.arrow span img {
position: absolute;
top: 11px;
right: -40px;
transform: rotate(-45deg);
}
.arrow-left {
background: url(http://lorempicsum.com/futurama/200/100/1) 0 0 no-repeat;
z-index: 3;
}
.separator {
left: 95px;
background: #fff;
width:90px;
height:90px;
transform: rotate(45deg);
position: absolute;
top: 4.5px;
z-index:2;
}
.arrow-right {
background-image: url(http://lorempicsum.com/simpsons/200/100/1);
position: absolute;
top: 0;
left: 150px;
z-index: 1;
}
<div class="wrap">
<div class="arrow arrow-left">
<span>
<img src="http://lorempicsum.com/futurama/200/100/1" alt="" />
</span>
</div>
<div class="separator"></div>
<div class="arrow arrow-right">
<span>
<img src="http://lorempicsum.com/simpsons/200/100/1" alt="" />
</span>
</div>
</div>
Also can viewed on my codepen : http://codepen.io/pik_at/pen/dPKXWp
Your approach is wrong: your images consist of a big transparent arrow-shaped "hole", that you fill with the background-color, and the parts external to the arrow (the three triangles), that are white:
And this is what is causing your problems. Example:
.arrow {
position: relative;
display: inline-block;
width: 125px;
height: 50px;
vertical-align: top;
background-image: url(http://fs1.directupload.net/images/150226/fag7h2u7.png);
background-repeat: no-repeat;
background-position: top left;
background-size: 125px;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
<div class="arrow red"></div>
<div class="arrow blue"></div>
<br>
<div class="arrow red" ></div>
<div class="arrow blue" style="left: -30px;"></div>
<br>
<div class="arrow red" ></div>
<div class="arrow blue" style="left: -30px; z-index: -1;"></div>
Solution: simply invert your approach, transforming your images into ones consisting of a big coloured arrow, and three transparent triangles at the sides; then you can overlap them whithout overriding the objects below (read: previous and next arrows).

How to slide a div over an image with CSS?

On a webpage I am working on, I have a div which contains an image and another div. The inner div is initially set to
opacity: 0;
so that it's not visible. The inner div should appear over my image when hovered. I have achieved this, but now I want to improve upon it further by having the 'overlay' div (which appears with an opacity of 0.5) slide down gradually over the image. I could do it theoretically with JavaScript but on this occasion it must be a pure CSS solution. So far my solution just makes the overlay div appear gradually (it fades in) but does not slide down as I have never done this in CSS alone.
See the image below to understand further:
The HTML:
<div class="img"> <img class="squareImg" src="img1.jpg"/><div class="overlay"> tweet This <br> Buy This</div></div>
<div class="img"> <img class="squareImg" src="img3.jpg"/></div>
<div class="img"> </img></div>
CSS
.overlay{
position: absolute;
width: 200px;
overflow-y: hidden;
transition-property: all;
transition-duration: .5s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
height: 200px;
background-color: red;
border: 1px solid white;
top: 10px;
left: 10px;
opacity: 0;
} .overlay:hover{
cursor:pointer;
opacity: 0.5;
z-index: 1;
}
.img{
position: relative;
margin-bottom: 10px;
border: 2px solid yellow;
background-color: black;
width: 200px;
height: 200px;
left: 50%;
margin-left: -110px;
padding: 10px;
}
Here it is with a slide down thanks to a height transition.
Improvements:
Instead of opacity, use background: rgba(255,0,0,0.5) so that the contents of the overlay remain fully opaque.
The transition property has been simplified to transition: all .5s
The outside border is created with box-shadow and the black border is now created with the border property instead of padding.
.overlay has a height of 0 and on hover it is given a height of 100%. It is stretched accross the image with the combination of left: 0 and right: 0
There is no set image size, the size of the <img> now controls the size of the border and overlay, allowing different image sizes.
Complete Example
.img {
position: relative;
border: 10px solid black;
box-shadow: 0 0 0 2px yellow;
display: inline-block;
vertical-align: top;
cursor: pointer;
margin: 10px;
}
.overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
transition: all .5s;
overflow: hidden;
height: 0;
background: rgba(255, 0, 0, 0);
}
.img:hover .overlay,
.overlay:hover {
height: 100%;
background: rgba(255, 0, 0, 0.5);
}
.img > img {
display: block;/* Prevent inline gap under image*/
}
<div class="img">
<img src="http://www.placehold.it/200" />
<div class="overlay">tweet This <br>Buy This</div>
</div>
<div class="img">
<img src="http://www.placehold.it/300" />
<div class="overlay">tweet This <br>Buy This</div>
</div>
You can just use simple transitions for this, rather than a keyframe animation
Example:
http://jsfiddle.net/realseanp/c4e08hy7/9/
HTML:
<div class="holder">
<div class="info">
<span>All your info</span>
<div class="overlay"></div>
</div>
</div>
CSS:
.holder{
position:relative;
height:200px;
width: 200px;
overflow: hidden;
border:1px solid #000;
z-index:3;
}
.info {
box-sizing: border-box;
height: 100%;
padding: 20px;
position: absolute;
top: -100%;
transition: top 0.5s ease 0s;
width: 100%;
z-index: 4;
}
.overlay {
background: none repeat scroll 0 0 #000;
height: 100%;
left: 0;
opacity: 0;
position: absolute;
top: 0;
width: 100%;
z-index: -1;
transition: 1s all;
}
.holder:hover .info{
top:0;
}
.holder:hover .overlay{
opacity: .85
}
Just a simple approach using the image as background:
.img{
position: relative;
background: none 50% / cover;
width: 200px;
height: 200px;
margin: 0 auto;
border: 10px solid #000;
box-shadow: 0 0 0 2px yellow;
}
.overlay{
position: absolute;
width: 100%;
height: 0%;
overflow: hidden;
transition: all .5s cubic-bezier(0, 1, 0.5, 1);
box-shadow: inset 0 0 0 1px white;
background: rgba(255,0,0,0.4); /* Don't use opacity but rgba on bg */
}
.img:hover .overlay{
height: 100%;
}
<div class="img" style="background-image:url(//placehold.it/300x300/aba)">
<div class="overlay">Tweet This <br> Buy This</div>
</div>
If you need to slide it down, you should use #keyframes:
.overlay:hover{
-webkit-animation: slide 5s; /* Chrome, Safari, Opera */
animation: slide 5s;
}
#keyframes slide {
from {height: 0px;}
to {height: 200px;}
}
/* Chrome, Safari, Opera */
#-webkit-keyframes slide {
from {height: 0px;}
to {height: 200px;}
}
You can achieve this by setting the .overlay with a negative top position and then you can target the sibling element with the + selector and change the top position to positive.
Also you can change the transition timing by setting the transition-duration: 2s; to 2 sec.
.overlay{
position: absolute;
width: 200px;
overflow-y: hidden;
transition-property: all;
transition-duration: 2s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
height: 200px;
background-color: red;
border: 1px solid white;
top: -200px;
left: 10px;
opacity: 0;
z-index:-1;
}
.squareImg:hover + .overlay, .overlay:hover {
cursor:pointer;
top:10px;
opacity: 0.5;
z-index: 1;
}
.img{
position:relative;
height:200px;
width: 200px;
overflow: hidden;
border:1px solid #000;
z-index:3;
margin-bottom: 10px;
border: 2px solid yellow;
background-color: black;
left: 50%;
margin-left: -110px;
padding: 10px;
}
DEMO http://jsfiddle.net/a_incarnati/c4e08hy7/8/