How to transition text using CSS onto an image with hover? - css

I spent the last two hours creating the following code, and I'm almost done. I just want the text to transition upwards on the image when hovering (image to still be visible). I have looked at other questions/answers that are similar, but the code they use isn't working with mine. Any suggestions?
HTML
<div class="One">
<p class="img-description">TEST!</p>
<img src="https://media2.giphy.com/media/vFKqnCdLPNOKc/giphy.gif?cid=ecf05e47eb603b7921279bc600f6c24e2c59bff5d8050e4b&rid=giphy.gif">
</div>
<div class="Two"> <p class="img-description-two">TEST!</p>
<img src="https://media0.giphy.com/media/26xBEez1vnVb2WgBq/200w.webp?cid=ecf05e47eb603b7921279bc600f6c24e2c59bff5d8050e4b&rid=200w.webp">
</div>
<div class="Three">
<p class="img-description-three">TEST!</p>
<img src="https://media.giphy.com/media/Y7l6oTRsxCC1a/giphy.gif">
</div>
CSS
body {
position: relative;
height: 500px;
border: #ffd28a 5px solid;
}
.One {
display: inline-flex;
justify-content: space-evenly;
background-color: #ffd28a;
width: 250px;
height: 250px;
position: relative;
top: 100px;
left: 110px;
margin: 0 100px 0 0;
border: 5px solid #ffd28a;
border-radius: 8px;
}
.img-description {
display: none;
width: 240px;
height: 240px;
background-color: #ffd28a;
position: relative;
margin: 0 90px 0 0;
border: 5px solid #ffd28a;
border-radius: 8px;
visibility: hidden;
opacity: 0;
}
.One:hover .img-description {
display: inline-block;
visibility: visible;
opacity: .5;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 5px;
border: 5px solid #ffd28a;
border-radius: 8px;
}
.Two {
display: inline-flex;
justify-content: space-evenly;
background-color: #ffd28a;
border: royalblue;
width: 250px;
height: 250px;
position: relative;
top: 100px;
left: 175px;
margin: 0 100px 0 0;
border: 5px solid #ffd28a;
border-radius: 8px;
}
.img-description-two {
display: none;
width: 240px;
height: 240px;
background-color: #ffd28a;
position: relative;
margin: 0 90px 0 0;
border: 5px solid #ffd28a;
border-radius: 8px;
visibility: hidden;
opacity: 0;
}
.Two:hover .img-description-two {
display: inline-block;
visibility: visible;
opacity: .5;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 5px;
border: 5px solid #ffd28a;
border-radius: 8px;
}
.Three {
display: inline-flex;
justify-content: space-evenly;
background-color: #ffd28a;
border: sandybrown;
width: 250px;
height: 250px;
position: relative;
top: 100px;
left: 220px;
margin: 0 100px 0 0;
border: 5px solid #ffd28a;
border-radius: 8px;
}
.img-description-three {
display: none;
width: 240px;
height: 240px;
background-color: #ffd28a;
position: relative;
margin: 0 90px 0 0;
border: 5px solid #ffd28a;
border-radius: 8px;
visibility: hidden;
opacity: 0;
}
.Three:hover .img-description-three {
display: inline-block;
visibility: visible;
opacity: .5;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 5px;
border: 5px solid #ffd28a;
border-radius: 8px;
}
img {
width: 250px;
height: 250px;
border: 5px ;
border-radius: 7px;
}

Basic idea is
Make container position to relative, hide overflowing content.
Make text absolute position and push it bottom (hide it).
Reveal it on hover
.img-container {
position: relative;
width: 300px;
height: 200px;
border: 1px solid #ccc;
overflow: hidden;
}
.img-container p {
background: #fff;
position: absolute;
bottom: -50px;
z-index: 1;
left: 35%;
transition: 1s;
}
.img-container:hover p {
bottom: 20px;
}
<div class="img-container">
<img src="https://i.picsum.photos/id/83/300/250.jpg" />
<p>Image Caption</p>
</div>

Related

HTML/CSS/SVG button not clickable.

<a class="round-button2" href="index.html" >
<img src="images/Palette.svg" alt="Palette" />
</a>
<a class="round-button3" href="index2.html" >
<img src="images/Chef.svg" alt="Chef" />
</a>
https://drive.google.com/open?id=1496aL5TpiqSO4pIh81wkq41Gn02OppE1 is the link for the svgs
https://codeitdown.com/css-round-buttons/ is a tutorial I followed; I recognize that its a 4 year old article; it maybe outdated. I was hoping that the community would be able to help.
I can get the svgs/circles to appear but they are not clickable to the index links I need them to go to. Im a novice coder/html user. I ran this in Adobe Dreamweaver.
CSS/style
.round-button2 {
width: 6%;
height: 0;
padding-bottom: 6%;
border-radius: 50%;
border: 2px solid #f5f5f5;
overflow: hidden;
position: relative;
background: #464646;
box-shadow: 0 0 3px gray;
}
.round-button2:hover #shape{
background: #262626;
}
.round-button2 img {
display: block;
width: 90%;
padding: 20%;
height: auto;
}
.round-button3 {
width: 6%;
height: 0;
padding-bottom: 6%;
border-radius: 50%;
border: 2px solid #f5f5f5;
overflow: hidden;
position: relative;
background: #464646;
box-shadow: 0 0 3px gray;
}
.round-button3:hover #shape{
background: #262626;
}
.round-button3 img {
display: block;
width: 90%;
padding-bottom: 15%;
padding-left: 20%;
padding-right: 12%;
padding-top: 20%;
height: auto;
}
change width to max-width 70%; with img classes.
and a class need correct width and height to be clickable.
check this fiddle (based your code and that guide).
http://jsfiddle.net/maxofpower/Jyjjx/13886/
.round-button {
width: 10%;
height: 0;
padding-bottom: 10%;
border-radius: 50%;
border: 2px solid #f5f5f5;
overflow: hidden;
background: #464646;
box-shadow: 0 0 3px gray;
}
.round-button:hover {
background: #262626;
}
.round-button img {
display: block;
width: 76%;
padding: 12%;
height: auto;
}
.round-button2 {
width: 6%;
height: 0;
padding-bottom: 6%;
border-radius: 50%;
border: 2px solid #f5f5f5;
overflow: hidden;
position: relative;
background: #464646;
box-shadow: 0 0 3px gray;
}
.round-button2:hover #shape{
background-color: #262626;
}
.round-button2 img{
display: block;
max-width: 70%;
height: auto;
padding:5px 8px 0;
}
.round-button3 img
{
display: block;
max-width: 70%;
height: auto;
padding:10px ;
}
.round-button3 {
width: 6%;
height: 0;
padding-bottom: 6%;
border-radius: 50%;
border: 2px solid #f5f5f5;
overflow: hidden;
position: relative;
background: #464646;
box-shadow: 0 0 3px gray;
}
.round-button3:hover #shape{
background: #262626;
}
<div class="round-button">
<a href="http://example.com">
<img src="http://codeitdown.com/media/Home_Icon.svg" alt="Home" />
</a>
</div>
<div class="round-button2">
<a href="index2.html" >
<img id=shape src="https://svgur.com/i/8as.svg" alt="pallete" />
</a>
</div>
<div class="round-button3">
<a href="index2.html" >
<img id=shape src="https://svgur.com/i/8bu.svg" alt="Chef" />
</a>
</div>
This was fixed by adding z-index: 100;

How to create shape with borders?

I want to create a black graphical element with a border that is positioned above the video feed pictured.
I have tried using :before and :after but the border complicates things. Any help would be greatly appreciated.
You can see in the photo that the feed is going below the border, since the graphic element is currently a square with a border radius
The below code is how I created the shape as pictured, but it is faulty since the feed goes above the border:
div.wrap1{
position: fixed;
height: 90vh;
bottom: 0;
left: 0;
width: 80vw;
margin-left: -120px;
.graphic-bg-1{
z-index: 5;
border: 3px solid #3AD8FF;
border-bottom: none;
border-radius: 120px;
position: relative;
width: 100%;
height: 100%;
}
.mask{
position: absolute;
height: 500px;
width: 100%;
background-color: black;
bottom: 0;
// margin-left: -120px;
z-index: 6;
}
}
div.wrap2{
position: fixed;
height: 75vh;
width: 100vw;
right: 0;
bottom: 10vh;
margin-right: calc(-80vw + 123px);
z-index: 7;
.graphic-bg-2{
z-index: 8;
border: 3px solid #3AD8FF;
border-top: transparent;
border-radius: 120px;
position: relative;
width: 100%;
height: 100%;
}
.mask2{
position: absolute;
height: 109px;
width: calc(100% - 3px);
background-color: black;
top: 0;
right: 0;
z-index: 8;
}
}
.first-element {
width: 150px;
height: 100px;
margin-top: 20px;
border-top: 1px solid #000;
border-right: 1px solid #000;
border-top-right-radius: 30px;
float: left;
}
.secound-element {
float: left;
width: 150px;
height: 100px;
margin-top: 70px;
border-bottom: 1px solid #000;
border-left: 1px solid #000;
border-bottom-left-radius: 30px;
margin-left: -1px;
}
<div class="first-element"></div>
<div class="secound-element"></div>
Try this it might helpful

how to make cornered button with css?

How do I make a button like this with pure CSS?
That's all that I've been capable of:
.sideMenuButton {
width: 100px;
height: 100px;
background: #6d1a3e;
position: relative;
transform: rotate(-90deg);
border: none;
}
.sideMenuButton:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
border-top: 29px solid #6d1a3e;
border-left: 29px solid #fff;
width: 42px;
height: 0;
}
<button type="button" class="sideMenuButton">X</button>
but it's not working right way
Just a quick try. I hope this could help you.
You can add text by the text attribute of the button.
.button-container{
width: 100px;
height: 100px;
overflow: hidden;
position:relative;
margin: 5px;
}
.button {
width: 148px;
height: 200px;
transform: rotateZ(45deg);
overflow: hidden;
position: absolute;
top: -68px;
left: -43px;
}
.button::before{
content: attr(text);
background: #6d1a3e;
display: block;
width: 100px;
height: 100px;
transform: rotateZ(-45deg);
position: absolute;
top: 50px;
left: 50px;
border: 5px solid #a5285e;
cursor: pointer;
box-sizing: border-box;
text-align: center;
vertical-align: middle;
line-height: 69px;
font-size: 2.5em;
color: white;
}
.button::after{
content: '';
display: block;
position: absolute;
border-bottom: 7px solid #a5285e;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
height: 0;
width: 41px;
transform: rotateZ(90deg);
top: 99px;
left: 120px;
cursor: pointer;
}
.other.button::before{
border-left: none;
border-top: none;
line-height: 80px;
font-size: 3em;
}
<div class="button-container">
<div class="button" text="PDF"></div>
</div>
<div class="button-container">
<div class="button other" text="☰"></div>
</div>

Slanted box shadow on left and right side

I am trying to make slanted box shadow on both sides of a div, which I have added here as an image.
The red part is indicating here shadow. actually color is not solid, it should gradually decrease when it is moving to outside from border.
Here is my contribution hope it gives you a baseline.
.box {
width: 150px;
height: 200px;
position: relative;
padding-left: 25px;
padding-right: 25px;
}
.box-content {
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
background-color: white;
border: 2px solid black;
width: 100%;
height: 100%;
position: relative;
}
.box::before {
content: '';
display: block;
border-top: 0;
border-bottom: 180px solid transparent;
border-right: 25px solid red;
position: absolute;
left: 0;
bottom: 0;
}
.box::after {
content: '';
display: block;
border-top: 0;
border-bottom: 180px solid transparent;
border-left: 25px solid red;
position: absolute;
right: -4px;
bottom: 0;
}
<div class="box">
<div class="box-content">
Box
</div>
</div>
Try this:
div{
width: 200px;
height: 200px;
border:1px solid black;
background: white;
}
div:before{
content:' ';
display:block;
width: 200px;
height:200px;
background: linear-gradient(transparent, black);
position: fixed;
transform: matrix3d(1.1,0,0.00,0,0.00,0.71,0.71,0.0007,0,-0.71,0.71,0,0,37,0,1); z-index: -1;
}
<div>Hello</div>
Using transform: skew() applied to the div's before and after
jsFiddle 1
code:
#test {
width: 150px;
height: 220px;
line-height: 220px;
background-color: white;
border: 2px black solid;
text-align: center;
position: relative;
margin: 10px 150px;
}
#test:before, #test:after {
width: 150px;
height: 200px;
position: absolute;
bottom: 0;
left: -11px;
z-index: -1;
content: " ";
display: block;
background-color: red;
transform: skew(5deg, 0);
}
#test:after {
transform: skew(-5deg, 0);
left: 11px;
}
<div id="test">Box</div>
EDIT : to give the shadow effect some real blur with gradient and transparency, we could make use of linear-gradient background with two rgba() values, as well as CSS blur() (1) filter.
jsFiddle 2
code:
#test {
width: 150px;
height: 220px;
line-height: 220px;
background-color: white;
border: 2px black solid;
text-align: center;
position: relative;
margin: 10px 150px;
}
#test:before, #test:after {
width: 150px;
height: 200px;
position: absolute;
bottom: 0;
left: -11px;
z-index: -1;
content: " ";
display: block;
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.7));
transform: skew(5deg, 0);
filter: blur(2px);
}
#test:after {
transform: skew(-5deg, 0);
left: 11px;
}
<div id="test">Box</div>
Notes:
(1) browser support for CSS filter

Connecting vertical lines between CSS elements that are part of a table's rows

I'd like to connect some CSS circles with a vertical line between them.
I've attempted to use the pseudo-element :after selector as follows:
.circle {
height: 45px;
width: 45px;
border-radius: 50%;
border: 2px solid;
position: relative;
border-color: #889EB7;
}
.circle:before {
content: "";
display: block;
position: absolute;
z-index: 1;
left: 18px;
top: 0;
bottom: 0;
border: 1px dotted;
border-width: 0 0 0 1px;
}
But I'm not getting any result at all.
Photo for reference of what I'd like to accomplish:
Use the :before pseudo element this way:
* {font-family: 'Segoe UI'; font-size: 10pt;}
.circle {position: relative; border: 2px solid #999; border-radius: 100%; width: 50px; line-height: 50px; text-align: center; margin-top: 50px; background-color: #fff; z-index: 2;}
.circle:first-child {margin-top: 0;}
.circle:before {position: absolute; border: 1px solid #999; width: 0; height: 50px; display: block; content: ''; left: 50%; z-index: 1; top: -54px; margin-left: -1px;}
.circle:first-child:before {display: none;}
<div class="circle">Step 1</div>
<div class="circle">Step 2</div>
<div class="circle">Step 3</div>
You do have to give your :before element a width and a height if you want ti to appear as a line. Have a look at this:
.circle {
height: 45px;
width: 45px;
border-radius: 50%;
border: 2px solid;
position: relative;
border-color: #889EB7;
}
.circle:before {
content: "";
display: block;
position: absolute;
z-index: 1;
top: 100%;
left: 50%;
border: 1px dotted;
border-width: 0 0 0 1px;
width: 1px;
height: 100px;
}
<div class='circle'></div>

Resources