I am trying to align text vertically and horizontally within a rounded div (with a border radius). I tried tags like position:absolute and relative
I tried adding this :
text-align: center;
display: inline-block;
overflow: hidden;
in my CSS but I had no success.
Below is the snippet. I wonder what the optimal solution would be without adding other divs. Thanks in advance.
.card-container2 {
cursor: pointer;
height: auto;
perspective: 600;
position: relative;
width: auto;
margin:auto;
align-contents:center;
}
.card-container {
cursor: pointer;
height: 350px;
perspective: 600;
position: relative;
width: 350px;
border-radius: 50%;
display:block;
margin-left:auto;
margin-right:auto;
}
.card {
height: 100%;
position: absolute;
transition: all 1s ease-in-out;
transform-style: preserve-3d;
width: 100%;
border-radius: 50%;
-moz-animation-name: dropCard;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
-moz-animation-duration: 0.3s;
-webkit-animation-name: dropCard;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-webkit-animation-duration:0.3s;
animation-name: dropCard;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 0.3s;
}
.card:hover {
transform: rotateY(180deg);
}
.card .side {
backface-visibility: hidden;
border-radius: 6px;
height: 100%;
position: absolute;
overflow: hidden;
width: 100%;
background:#000;
border-radius: 50%;
}
.card .back {
background: #F1F1F1;
color: #000;
line-height: 24px;
font-weight: bold;
text-align: center;
border-radius: 50%;
transform: rotateY(180deg);
}
#-moz-keyframes dropCard {
0% {
-moz-transform: translateY(-100px);
}
100% {
-moz-transform: translateY(0);
}
}
#-webkit-keyframes dropCard {
0% {
-webkit-transform: translateY(-100px);
}
100% {
-webkit-transform: translateY(0);
}
}
#keyframes dropCard {
0% {
transform: translateY(-100px);
}
100% {
transform: translateY(0);
}
}
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto }
<p style="text-align: center;"> </p>
<div class="card-container2">
<div class="card-container">
<div class="card">
<div class="side" style="text-align: center;"><img class="displayed" src="IMAGE" alt="" width="350" height="350" /></div>
<div class="side back">
<p><span style="font-size: 14pt; font-family: arial, helvetica, sans-serif; color: #000;">Campaign Name: 11111111 </span></p>
<p><span style="color: #000; font-size: 14pt;"><span style="font-family: arial, helvetica, sans-serif;">Campaign Dates: </span><span style="font-family: arial, helvetica, sans-serif;">333333333333333 - 22222222222 </span></span></p>
<p><span style="color: #000; font-size: 14pt;"> </span></p>
<p><span style="color: #000; font-size: 14pt;">Length of campaign:4444444444444 </span></p>
<p><span style="color: #000; font-size: 14pt;">Days left of campaign: 55555555555555555} </span></p>
</div>
</div>
</div>
</div>
Is your plan is to align text within backside rounded div .back .side properly in center, then remove margin from <p> tag and add padding-top to .back
.card .back {
background: #F1F1F1;
color: #000;
line-height: 24px;
font-weight: bold;
text-align: center;
border-radius: 50%;
transform: rotateY(180deg);
padding-top:75px;
box-sizing:border-box;
}
p{
margin:5px 0px;
text-align:center;
}
.card-container2 {
cursor: pointer;
height: auto;
perspective: 600;
position: relative;
width: auto;
margin:auto;
align-contents:center;
}
.card-container {
cursor: pointer;
height: 350px;
perspective: 600;
position: relative;
width: 350px;
border-radius: 50%;
display:block;
margin-left:auto;
margin-right:auto;
}
.card {
height: 100%;
position: absolute;
transition: all 1s ease-in-out;
transform-style: preserve-3d;
width: 100%;
border-radius: 50%;
-moz-animation-name: dropCard;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
-moz-animation-duration: 0.3s;
-webkit-animation-name: dropCard;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-webkit-animation-duration:0.3s;
animation-name: dropCard;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 0.3s;
}
.card:hover {
transform: rotateY(180deg);
}
.card .side {
backface-visibility: hidden;
border-radius: 6px;
height: 100%;
position: absolute;
overflow: hidden;
width: 100%;
background:#000;
border-radius: 50%;
}
.card .back {
background: #F1F1F1;
color: #000;
line-height: 24px;
font-weight: bold;
text-align: center;
border-radius: 50%;
transform: rotateY(180deg);
padding-top:75px;
box-sizing:border-box;
}
p{
margin:5px 0px;
text-align:center;
}
#-moz-keyframes dropCard {
0% {
-moz-transform: translateY(-100px);
}
100% {
-moz-transform: translateY(0);
}
}
#-webkit-keyframes dropCard {
0% {
-webkit-transform: translateY(-100px);
}
100% {
-webkit-transform: translateY(0);
}
}
#keyframes dropCard {
0% {
transform: translateY(-100px);
}
100% {
transform: translateY(0);
}
}
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto }
<p style="text-align: center;"> </p>
<div class="card-container2">
<div class="card-container">
<div class="card">
<div class="side" style="text-align: center;"><img class="displayed" src="IMAGE" alt="" width="350" height="350" /></div>
<div class="side back">
<p><span style="font-size: 14pt; font-family: arial, helvetica, sans-serif; color: #000;">Campaign Name: 11111111 </span></p>
<p><span style="color: #000; font-size: 14pt;"><span style="font-family: arial, helvetica, sans-serif;">Campaign Dates: </span><span style="font-family: arial, helvetica, sans-serif;">333333333333333 - 22222222222 </span></span></p>
<p><span style="color: #000; font-size: 14pt;"> </span></p>
<p><span style="color: #000; font-size: 14pt;">Length of campaign:4444444444444 </span></p>
<p><span style="color: #000; font-size: 14pt;">Days left of campaign: 55555555555555555} </span></p>
</div>
</div>
</div>
</div>
Since the requirement is, as mentioned in the comments, to center the content in the circle vertically and horizontally, we can use flexbox for that.
Like so:
* {
margin: 0;
padding: 0;
}
.card-container2 {
cursor: pointer;
height: auto;
perspective: 600;
position: relative;
width: auto;
margin: auto;
text-align: center;
}
.card-container {
cursor: pointer;
height: 350px;
perspective: 600;
position: relative;
width: 350px;
border-radius: 50%;
display: block;
margin-left: auto;
margin-right: auto;
}
.card {
height: 100%;
position: absolute;
transition: all 1s ease-in-out;
transform-style: preserve-3d;
width: 100%;
border-radius: 50%;
}
.card .side {
backface-visibility: hidden;
border-radius: 6px;
height: 100%;
position: absolute;
overflow: hidden;
width: 100%;
background: #000;
border-radius: 50%;
display: flex;
flex-direction: column;
justify-content: center;
text-align:center;
}
.card .back {
background: #F1F1F1;
color: #000;
line-height: 24px;
font-weight: bold;
text-align: center;
border-radius: 50%;
}
<div class="card-container2">
<div class="card-container">
<div class="card">
<div class="side" style="text-align: center;">
<img class="displayed" src="IMAGE" alt="" width="350" height="350" />
</div>
<div class="side back">
<p><span style="font-size: 14pt; font-family: arial, helvetica, sans-serif; color: #000;">Campaign Name: 11111111 </span>
</p>
<p><span style="color: #000; font-size: 14pt;"><span style="font-family: arial, helvetica, sans-serif;">Campaign Dates: </span><span style="font-family: arial, helvetica, sans-serif;">333333333333333 - 22222222222 </span></span>
</p>
<p><span style="color: #000; font-size: 14pt;"> </span>
</p>
<p><span style="color: #000; font-size: 14pt;">Length of campaign:4444444444444 </span>
</p>
<p><span style="color: #000; font-size: 14pt;">Days left of campaign: 55555555555555555 </span>
</p>
</div>
</div>
</div>
</div>
Note that this does not address any overflow issues as you can see.
Add this to your CSS just after your .card .back line..
.back>p:first-child {
padding-top: 40px;
}
EDIT:Also you can reduce the line height in .card .back to prevent overflow. I reduced it to 20px. Seemed to fit better, but that is a matter of preference..
Simply add a padding of 10% to .card .back
.card-container2 {
cursor: pointer;
height: auto;
perspective: 600;
position: relative;
width: auto;
margin:auto;
align-contents:center;
}
.card-container {
cursor: pointer;
height: 350px;
perspective: 600;
position: relative;
width: 350px;
border-radius: 50%;
display:block;
margin-left:auto;
margin-right:auto;
}
.card {
height: 100%;
position: absolute;
transition: all 1s ease-in-out;
transform-style: preserve-3d;
width: 100%;
border-radius: 50%;
-moz-animation-name: dropCard;
-moz-animation-iteration-count: 1;
-moz-animation-timing-function: ease-in;
-moz-animation-duration: 0.3s;
-webkit-animation-name: dropCard;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in;
-webkit-animation-duration:0.3s;
animation-name: dropCard;
animation-iteration-count: 1;
animation-timing-function: ease-in;
animation-duration: 0.3s;
}
.card:hover {
transform: rotateY(180deg);
}
.card .side {
backface-visibility: hidden;
border-radius: 6px;
height: 100%;
position: absolute;
overflow: hidden;
width: 100%;
background:#000;
border-radius: 50%;
}
.card .back {
background: #F1F1F1;
color: #000;
padding:10%;
line-height: 24px;
font-weight: bold;
text-align: center;
border-radius: 50%;
transform: rotateY(180deg);
}
#-moz-keyframes dropCard {
0% {
-moz-transform: translateY(-100px);
}
100% {
-moz-transform: translateY(0);
}
}
#-webkit-keyframes dropCard {
0% {
-webkit-transform: translateY(-100px);
}
100% {
-webkit-transform: translateY(0);
}
}
#keyframes dropCard {
0% {
transform: translateY(-100px);
}
100% {
transform: translateY(0);
}
}
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto }
<p style="text-align: center;"> </p>
<div class="card-container2">
<div class="card-container">
<div class="card">
<div class="side" style="text-align: center;"><img class="displayed" src="IMAGE" alt="" width="350" height="350" /></div>
<div class="side back">
<p><span style="font-size: 14pt; font-family: arial, helvetica, sans-serif; color: #000;">Campaign Name: 11111111 </span></p>
<p><span style="color: #000; font-size: 14pt;"><span style="font-family: arial, helvetica, sans-serif;">Campaign Dates: </span><span style="font-family: arial, helvetica, sans-serif;">333333333333333 - 22222222222 </span></span></p>
<p><span style="color: #000; font-size: 14pt;"> </span></p>
<p><span style="color: #000; font-size: 14pt;">Length of campaign:4444444444444 </span></p>
<p><span style="color: #000; font-size: 14pt;">Days left of campaign: 55555555555555555} </span></p>
</div>
</div>
</div>
</div>
Related
.film{
text-align: center;
width: 234px;
min-height: 311px;
position: relative;
z-index: 1;
overflow: hidden;
}
.poster{
width: 234px;
height: 311px;
-moz-transition: all 1s ease-out;
-o-transition: all 1s ease-out;
-webkit-transition: all 1s ease-out;
display: block;
}
.poster:hover{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
}
.film_name{
font-size: 24px;
word-wrap: break-word;
font-family: 'Roboto', 'Arial', 'Tahoma', sans-serif;
font-weight: 700;
}
.year{
color: #00dfff;
}
<div class="film">
<a href="#" target="_blank">
<img class="poster" src="https://st.kp.yandex.net/images/poster/sm_3362295.jpg" alt="Годзилла 2: Король монстров">
<div class="triangle">
<span class="triangle__line"></span>
<span class="triangle__line"></span>
<span class="triangle__line"></span>
</div>
<div class="film_name">Годзилла 2: Король монстров</div>
<div class="year">2019</div>
</div>
</a>
</div>
How to make the picture go beyond the vertical?
The height (.film{ min-height: 311px;}) property does not need to be changed.
Change overflow: hidden; to overflow: visible; in the film class. See below:
.film {
text-align: center;
width: 234px;
min-height: 311px;
position: relative;
z-index: 1;
overflow: visible;
}
add div (poster-panel) to image tag and set overflow:hidden... so the image will stretch inside the poster-panel div.
.film{
text-align: center;
width: 234px;
min-height: 311px;
position: relative;
z-index: 1;
overflow: hidden;
}
.poster-panel{
overflow: hidden;
}
.poster{
width: 234px;
height: 311px;
-moz-transition: all 1s ease-out;
-o-transition: all 1s ease-out;
-webkit-transition: all 1s ease-out;
display: block;
}
.poster:hover{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
}
.film_name{
font-size: 24px;
word-wrap: break-word;
font-family: 'Roboto', 'Arial', 'Tahoma', sans-serif;
font-weight: 700;
}
.year{
color: #00dfff;
}
<div class="film">
<a href="#" target="_blank">
<div class="poster-panel">
<img class="poster" src="https://st.kp.yandex.net/images/poster/sm_3362295.jpg" alt="Годзилла 2: Король монстров">
</div>
<div class="triangle">
<span class="triangle__line"></span>
<span class="triangle__line"></span>
<span class="triangle__line"></span>
</div>
<div class="film_name">Годзилла 2: Король монстров</div>
<div class="year">2019</div>
</div>
</a>
</div>
I am coding a page to select different products. each 'bild box' in my HTML is supposed to display a product and when you hover with you mouse over it, it zooms into the picture and a few other styling effects happen. When hovering over the boxes you can see, that randomly the boxes zoom and it looks glitchy. Here is a demonstration of the effect: https://streamable.com/wei69
I have tried to specify the different hover boxes which makes the code unnecessarily long and didn't fix the problem. Before I did this there were no classes like 'title1, title2' it was only 'title'.
I also tried different browsers and in Safari the effect isn't that bad but it is still not user friendly.
Here is my code:
#flex-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-pack: distribute;
justify-content: space-around;
}
.bildbox1,
.bildbox2,
.bildbox3,
.bildbox4,
.bildbox5,
.bildbox6 {
width: 100vw;
margin-left: calc(50% - 50vw);
height: 300px;
overflow: hidden;
text-align: center;
}
.bild1,
.bild2,
.bild3,
.bild4,
.bild5 {
width: 100%;
height: 100%;
background-color: black;
/* fallback color */
background-position: center;
background-size: cover;
-webkit-transition: all .3s ease;
}
.bild1 {
background-image: url("//cdn.shopify.com/s/files/1/0031/3252/2611/files/selfie-413162_960_720_large.jpg?v=1549398130");
}
.bild2 {
background-image: url("//cdn.shopify.com/s/files/1/0031/3252/2611/files/selfie-413162_960_720_large.jpg?v=1549398130");
}
.bild3 {
background-image: url("//cdn.shopify.com/s/files/1/0031/3252/2611/files/selfie-413162_960_720_large.jpg?v=1549398130");
}
.bild4 {
background-image: url("//cdn.shopify.com/s/files/1/0031/3252/2611/files/selfie-413162_960_720_large.jpg?v=1549398130");
}
.bild5 {
background-image: url("//cdn.shopify.com/s/files/1/0031/3252/2611/files/selfie-413162_960_720_large.jpg?v=1549398130");
}
.textbox {
background-color: #F2F2F2;
height: 100%;
padding-top: 20%;
text-align: center;
}
.textbox p {
color: darkgrey;
}
.point1,
.point2,
.point3,
.point4,
.point5 {
width: 75px;
margin: auto;
position: absolute;
top: 10px;
left: 0;
bottom: 0;
right: 0;
height: 1px;
background: white;
-webkit-transition: width .3s ease;
-o-transition: width .3s ease;
transition: width .3s ease;
display: none;
}
.konfigurieren-button1,
.konfigurieren-button2,
.konfigurieren-button3,
.konfigurieren-button4,
.konfigurieren-button5 {
background: #E30D27;
color: white;
padding: 0 10px;
text-align: center;
height: 30px;
line-height: 1.2;
vertical-align: top;
font-weight: bold;
font-size: 10px;
#include inline-flexbox();
#include align-items(center);
#include justify-content(center);
-webkit-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
-webkit-appearance: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-smoothing: antialiased;
border-radius: 100px;
position: relative;
top: 50px;
z-index: 99;
}
.title1,
.title2,
.title3,
.title4,
.title5 {
color: #ffffff !important;
font-family: sans-serif;
text-align: center;
margin: auto;
position: relative;
top: 100px;
left: 0;
bottom: 0;
right: 0;
height: 50px;
display: block;
color: white;
padding: 25%;
}
.konfigurieren-button1:hover,
.konfigurieren-button2:hover,
.konfigurieren-button3:hover,
.konfigurieren-button4:hover,
.konfigurieren-button5:hover,
{
color: black;
background-color: white;
}
#media (hover: hover) {
.bildbox1:hover .bild1,
.bildbox1:focus .bild1 {
-webkit-transform: scale(1.15);
-ms-transform: scale(1.15);
transform: scale(1.15);
}
.bildbox2:hover .bild2,
.bildbox2:focus .bild2 {
-webkit-transform: scale(1.15);
-ms-transform: scale(1.15);
transform: scale(1.15);
}
.bildbox3:hover .bild3,
.bildbox3:focus .bild3 {
-webkit-transform: scale(1.15);
-ms-transform: scale(1.15);
transform: scale(1.15);
}
.bildbox4:hover .bild4,
.bildbox4:focus .bild4 {
-webkit-transform: scale(1.15);
-ms-transform: scale(1.15);
transform: scale(1.15);
}
.bildbox5:hover .bild5,
.bildbox5:focus .bild5 {
-webkit-transform: scale(1.15);
-ms-transform: scale(1.15);
transform: scale(1.15);
}
.bildbox1:hover .title1,
.bildbox2:hover .title2,
.bildbox3:hover .title3,
.bildbox4:hover .title4,
.bildbox5:hover .title5 {
color: #ffffff !important;
font-family: sans-serif;
text-align: center;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 50px;
opacity: 1.0;
color: white;
padding: 25%;
}
.point1,
.point2,
.point3,
.point4,
.point5 {
width: 0px;
display: initial;
top: 17%;
}
.title1,
.title2,
.title3,
.title4,
.title5 {
opacity: 0.0;
position: absolute;
-webkit-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
top: 0;
}
.konfigurieren-button1,
.konfigurieren-button2,
.konfigurieren-button3,
.konfigurieren-button4,
.konfigurieren-button5 {
opacity: 0.0;
-webkit-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
margin-top: 135px;
}
.bildbox1:hover .konfigurieren-button1,
.bildbox2:hover .konfigurieren-button2,
.bildbox3:hover .konfigurieren-button3,
.bildbox4:hover .konfigurieren-button4,
.bildbox5:hover .konfigurieren-button5 {
opacity: 1.0;
}
.bildbox1:hover .point1,
.bildbox2:hover .point2,
.bildbox3:hover .point3,
.bildbox4:hover .point4,
.bildbox5:hover .point5 {
width: 75px;
}
}
#media (min-width: 900px) {
.bildbox1,
.bildbox2,
.bildbox3,
.bildbox4,
.bildbox5,
.bildbox6 {
width: 400px;
}
}
<div id="flex-container">
<div class="bildbox1">
<div class="bild1">
<span class="title1"> Text 1</span>
<a href="">
<button class="konfigurieren-button1"> Button 1</button>
</a>
<div class="point1"></div>
</div>
</div>
<div class="bildbox2">
<div class="bild2">
<span class="title2"> Text 2</span>
<button class="konfigurieren-button2">Button 2</button>
<div class="point2"></div>
</div>
</div>
<div class="bildbox3">
<div class="bild3">
<span class="title3">Text 3</span>
<button class="konfigurieren-button3">Button 3</button>
<div class="point3"></div>
</div>
</div>
<div class="bildbox4">
<div class="bild4">
<span class="title4"> Text 4</span>
<button class="konfigurieren-button4">Button 4</button>
<div class="point4"></div>
</div>
</div>
<div class="bildbox5">
<div class="bild5">
<span class="title5"> Text 5</span>
<button class="konfigurieren-button5">Button 5</button>
<div class="point5"></div>
</div>
</div>
<div class="bildbox6">
<div class="textbox">
<h3> header </h3>
<p> paragraph
</p>
</div>
</div>
</div>
Add position: relative; to you .bildbox classes.
.bildbox1,
.bildbox2,
.bildbox3,
.bildbox4,
.bildbox5,
.bildbox6 {
width: 100vw;
margin-left: calc(50% - 50vw);
height: 300px;
overflow: hidden;
text-align: center;
position: relative; /* <-- Add this here */
}
You have position: absolute; elements (your .point classes) that are all over the place. They need to be contained in the "boxes". When you are hovering, those position absolute elements are outside the box and overlapping other boxes.
Remember when using position absolute, that element with position itself of the first parent with a position other than static, else it will be the document window.
On a side note, is there a reason you are using classes like ids? Why do you have .bildbox1, .bildbox2, etc when you should just have 1 .bildbox class.
I'm having an issue with an animation on one of my images. I want the image to resize on hover with a transition time (and then have a transition time back to the original size when the mouse moves off the image) but then when i resize the window and the image resizes accordingly, it resizes with the transition time . Does anyone know a way to get around this?
<div class="column">
<a href="-----.html">
<img src="-----.jpg">
</a>
</div>
.column img{
filter: brightness(0.8);
transition: 0.6s ease;
width:100%;
height: calc(100vh - 300px);
}
.column:hover img{
filter: brightness(0.5);
width:110%;
transform: translate(-5%,-5%);
transition: 0.6s ease;
height: calc(110vh - 300px);
}
I can see why the transition applies to the image when the window resizes, but i don't know how else to get the transition to apply when the mouse moves away. Can anyone suggest a way around this?
Gif of resizing issue
edit: full code posted below
html {
height: 100%;
}
body {
min-width: 600px;
min-height: 100%;
position: relative;
font-family: Helvetica;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: #FFFFFF;
overflow-y: hidden;
}
/*Header*/
header {
background: #FFFFFF;
color: #F89828;
height: 159px;
}
header img {
margin-left: calc(50% - 122px);
margin-top: 60px;
margin-bottom: 60px;
height: 39px;
width: 244px;
}
.column {
float: left;
position: relative;
text-align: center;
width: 50%;
padding: 0px;
overflow: hidden;
height: calc(100vh - 239px);
}
.row .column img {
background: #000000;
width: 100%;
filter: brightness(0.8);
height: calc(100vh - 239px);
transition: 0.6s ease;
}
.row .column:hover img {
transition: 0.6s ease;
width: 110%;
cursor: pointer;
transform: translate(-5%, -5%);
filter: brightness(0.5);
height: calc(110vh - 239px);
}
.centered {
color: #FFFFFF;
position: absolute;
font-size: 4em;
font-weight: bold;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-decoration: none;
}
/*footer*/
footer {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 0;
width: 100%;
height: 80px;
color: #FFFFFF;
background-color: #808080;
font-weight: bold;
}
<body>
<header>
<img src="https://picsum.photos/400/100/?random">
</header>
<div class="row">
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random">
<div class="centered">1</div>
</a>
</div>
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random" />
<div class="centered">2</div>
</a>
</div>
</div>
<footer>
<p>This is where I would put some filler text, if I had any</p>
</footer>
</body>
You could set the transition on your image only when the window is hovered. This way, on resize it won't affect your element anymore, but on your element's hover and mouseout it will still be active.
/* when hovering the page */
:hover .row .column img {
transition: 0.6s ease;
}
.row .column img {
background: #000000;
width: 100%;
filter: brightness(0.8);
height: calc(80vh - 10px);
/* transition: 0.6s ease; [removed]*/
}
.row .column:hover img {
/* transition: 0.6s ease; [useless]*/
width: 110%;
cursor: pointer;
transform: translate(-5%, -5%);
filter: brightness(0.5);
height: calc(80vh - 10px);
}
.column {
float: left;
position: relative;
text-align: center;
width: 50%;
padding: 0px;
overflow: hidden;
height: calc(60vh - 10px);
}
<div class="row">
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random">
<div class="centered">1</div>
</a>
</div>
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random" />
<div class="centered">2</div>
</a>
</div>
</div>
But using this solution, if mousing-out from the document itself, then the transition will also get disabled...
Unfortunately, I don't see any other solution than that, except using js of course.
(function(){
let timer;
const docEl = document.documentElement;
addEventListener('resize', e => {
clearTimeout(timer);
docEl.classList.add('resizing');
timer = setTimeout(_ => docEl.classList.remove('resizing'), 200);
});
})();
:root.resizing .row .column img {
transition: none;
}
.row .column img {
background: #000000;
width: 100%;
filter: brightness(0.8);
height: calc(80vh - 10px);
transition: 0.6s ease;
}
.row .column:hover img {
width: 110%;
cursor: pointer;
transform: translate(-5%, -5%);
filter: brightness(0.5);
height: calc(80vh - 10px);
}
.column {
float: left;
position: relative;
text-align: center;
width: 50%;
padding: 0px;
overflow: hidden;
height: calc(60vh - 10px);
}
<div class="row">
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random">
<div class="centered">1</div>
</a>
</div>
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random" />
<div class="centered">2</div>
</a>
</div>
</div>
You need to assign width without hover for animation on mouse out, check it
.column img{
filter: brightness(0.8);
transition: 0.6s ease;
width:35%;
}
.column:hover img{
filter: brightness(0.5);
width:110%;
transform: translate(-5%,-5%);
transition: 0.6s ease;
}
<div class="column">
<a href="-----.html">
<img src="https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
</a>
</div>
Try this:
.container {
display: inline-block;
width: 64px;
height: 64px;
perspective: 700px;
}
.icon, .icon-one, .icon-two{
position: absolute;
transition: all .5s;
transform-style: preserve-3d;
backface-visibility: hidden;
width:50px;
height:50px;
}
}
.icon-wrap .icon-one{
width:150px;
height:150px;
transform:translate(0%,0%);}
/* ::: HOVER EFFECTS (Remove Automated for this to work) */
.icon-wrap:hover .icon{ transform: translate(0%,0%); }
/* ::: AUTOMATED EFFECTS */
.icon-wrap .icon{
animation: icon-wrap 5s 1s infinite alternate ease-in-out;
-webkit-animation: icon-wrap 5s 1s infinite alternate ease-in-out;
}
#keyframes icon-wrap {
0% { transform:translate(0%,0%); }
100% { transform: translate(40%,40%)scale(2);
width:150px;
height:150px;
}
}
#-webkit-keyframes icon-wrap {
0% { transform: translate(0%,0%); }
100% { transform: translate(40%,40%) scale(2);
width:150px;
height:150px; }
}
<div class="container icon-wrap">
<div class="icon">
<div class="icon-one">
<a href="-----.html">
<img src="https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
</a>
</div>
</div>
</div>
.container {
display: inline-block;
width: 64px;
height: 64px;
perspective: 700px;
}
.icon, .icon-one, .icon-two{
position: absolute;
transition: all .5s;
transform-style: preserve-3d;
backface-visibility: hidden;
width:50px;
height:50px;
}
}
.icon-wrap .icon-one{
width:150px;
height:150px;
transform:translate(40%,40%)scale(2);}
/* ::: HOVER EFFECTS (Remove Automated for this to work) */
.icon-wrap:hover .icon{ transform: translate(40%,40%)scale(2); }
/* ::: AUTOMATED EFFECTS */
.icon-wrap .icon{
animation: icon-wrap 5s 1s infinite alternate ease-in-out;
-webkit-animation: icon-wrap 5s 1s infinite alternate ease-in-out;
}
<div class="container icon-wrap">
<div class="icon">
<div class="icon-one">
<a href="-----.html">
<img src="https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
</a>
</div>
</div>
</div>
Try using scale(2) it's working well for me.
But you need to change translate() value as per the scale() value as per your requirement.
.column img{
filter: brightness(0.8);
transition: 0.6s ease;
}
.column:hover img{
filter: brightness(0.5);
transform: translate(50%,50%) scale(2);
transition: 0.6s ease;
}
<div class="column">
<a href="-----.html">
<img src="https://picsum.photos/300/100/?random">
</a>
</div>
Updated with your code.
html {
height: 100%;
}
body {
min-width: 600px;
min-height: 100%;
position: relative;
font-family: Helvetica;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: #FFFFFF;
overflow-y: hidden;
}
/*Header*/
header {
background: #FFFFFF;
color: #F89828;
height: 159px;
}
header img {
margin-left: calc(50% - 122px);
margin-top: 60px;
margin-bottom: 60px;
height: 39px;
width: 244px;
}
.column {
float: left;
position: relative;
text-align: center;
width: 50%;
padding: 0px;
overflow: hidden;
height: calc(100vh - 239px);
}
.row .column img {
background: #000000;
width: 100%;
filter: brightness(0.8);
height: calc(100vh - 239px);
transition: 0.6s ease;
}
.row .column:hover img {
transition: 0.6s ease;
width: 110%;
cursor: pointer;
transform: translate(-10%,-10%) scale(1.3);
filter: brightness(0.5);
height: calc(110vh - 239px);
}
.centered {
color: #FFFFFF;
position: absolute;
font-size: 4em;
font-weight: bold;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-decoration: none;
}
/*footer*/
footer {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
bottom: 0;
width: 100%;
height: 80px;
color: #FFFFFF;
background-color: #808080;
font-weight: bold;
}
<body>
<header>
<img src="https://picsum.photos/400/100/?random">
</header>
<div class="row">
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random">
<div class="centered">1</div>
</a>
</div>
<div class="column">
<a href="---.html">
<img src="https://picsum.photos/300/100/?random" />
<div class="centered">2</div>
</a>
</div>
</div>
<footer>
<p>This is where I would put some filler text, if I had any</p>
</footer>
</body>
Hope this was helpful for you.
There is background colour showing between image divs. I thought it might have something to do with margins. Even setting the div to absolute positioning and the parent to relative doesn't work. The picture still won't show without it being relative. (robot2.jpg in div sec, sectThree).
Here's the website: thomasogbourne.me
html,
body {
margin: 0px;
height: 100%;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
background-color: #000000;
}
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin-bottom: 20px;
}
/*
nav {
position: fixed;
width: 100%;
height: 50px;
background-color: rgba(0,0,0,.5);
z-index: 99;
text-align: center;
}
nav a {
text-decoration: none;
color: #fff;
margin-left: 30px;
line-height: 50px;
}*/
.sect {
position: rela;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
}
.subSection {
height: 30%;
}
.smallsubSection {
height: 20%;
}
.sectOne {
background-image: url("/Images/CX750Msmall.jpg");
background-attachment: fixed;
}
.sectTwo {
background-image: url("/Images/drone.jpg");
position: relative;
top: -90px;
z-index: -1
}
.sectThree {
background-image: url("/Images/robot2.jpg");
position: absolute;
top: -150px;
background-repeat: space;
}
#aboutSection {
background: #648880;
background: linear-gradient(to right, #f6f1d3, #648880 85%, #293f50);
}
#gearSection {
background: #0083FF;
background: linear-gradient(#3943DA, #00F3FF);
height: 66%;
}
#contactSection {
background: #648880;
background: linear-gradient(#DEDEDE, #898989 85%);
}
.smallsubSection {
font-family: "Arial Narrow", Arial, sans-serif;
font-size: 24px;
font-style: normal;
font-variant: normal;
font-weight: 500;
line-height: 26.4px;
}
#bigname {
font-family: "Luckiest Guy";
font-size: 45px;
font-style: normal;
font-variant: normal;
font-weight: 500;
line-height: 26.4px;
letter-spacing: 2px;
text-decoration: overline underline;
color: #D5D5D5;
text-align: center;
position: absolute;
top: 33%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
/* MENU START */
nav.container {
margin: 0 auto;
padding: 30px 3em;
background-color: #000040;
position: fixed;
width: 40%;
text-align: center;
list-style: none;
margin-left: 27.5%;
z-index: 1;
}
nav.container a {
color: #fff;
text-decoration: none;
margin: 0 10px;
padding: 10px 10px;
position: relative;
z-index: 0;
cursor: pointer;
font-family: "Rockwell Extra Bold", "Rockwell Bold", monospace;
font-size: 25px;
padding: 10px;
}
nav.borderXwidth a:before,
nav.borderXwidth a:after {
position: absolute;
opacity: 0;
width: 0%;
height: 2px;
content: '';
background: #FFF;
transition: all 0.3s;
}
nav.borderXwidth a:before {
left: 0px;
top: 0px;
}
nav.borderXwidth a:after {
right: 0px;
bottom: 0px;
}
nav.borderXwidth a:hover:before,
nav.borderXwidth a:hover:after {
opacity: 1;
width: 100%;
}
/* MENU END */
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 13px 21px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 24px;
margin: 4px 2px;
cursor: pointer;
transition-duration: 0.4s;
position: relative;
bottom: -90px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
width: 150px;
}
.button1 {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.button2:hover {
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}
/* SCROLLING TEXT MAIN SECTION */
.content {
position: absolute;
top: 144%;
left: 54%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-size: 35px;
line-height: 40px;
font-family: 'Lato', sans-serif;
color: #ecf0f1;
height: 160px;
overflow: hidden;
zoom: 3.5;
-moz-transform: scale(3.5);
}
.visible {
font-weight: 600;
overflow: hidden;
height: 40px;
padding: 0 40px;
}
.visible:before {
content: '';
left: 0;
line-height: 40px;
}
.visible:after {
content: '';
position: absolute;
right: -80px;
line-height: 40px;
}
.visible:after,
.visible:before {
position: absolute;
top: 0;
color: #16a085;
font-size: 42px;
-webkit-animation-name: opacity;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-name: opacity;
animation-name: opacity;
-webkit-animation-duration: 2s;
animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
p {
display: inline;
float: left;
margin: 0;
left: 40px;
}
ul {
margin-top: 0;
padding-left: 230px;
text-align: left;
list-style: none;
-webkit-animation-name: change;
-webkit-animation-duration: 6s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-name: change;
animation-name: change;
-webkit-animation-duration: 6s;
animation-duration: 6s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
ul li {
line-height: 40px;
margin: 0;
}
li {
width: 270px
}
#-webkit-keyframes opacity {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#-webkit-keyframes change {
0%,
12%,
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
17%,
29% {
-webkit-transform: translateY(-25%);
transform: translateY(-25%);
}
34%,
46% {
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
51%,
63% {
-webkit-transform: translateY(-75%);
transform: translateY(-75%);
}
68%,
80% {
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
85%,
97% {
-webkit-transform: translateY(-25%);
transform: translateY(-25%);
}
}
#keyframes opacity {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#keyframes change {
0%,
12%,
100% {
-webkit-transform: translateY(0);
transform: translateY(0);
}
17%,
29% {
-webkit-transform: translateY(-25%);
transform: translateY(-25%);
}
34%,
46% {
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
51%,
63% {
-webkit-transform: translateY(-75%);
transform: translateY(-75%);
}
68%,
80% {
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
85%,
97% {
-webkit-transform: translateY(-25%);
transform: translateY(-25%);
}
}
<body>
<nav class="container borderXwidth">
<a id="home" href="#homeSection">HOME</a>
<a id="about" href="#aboutSection">ABOUT</a>
<a id="gear" href="#gearSection">MY GEAR</a>
<a id="portfolio" href="#portfolioSection">PORTFOLIO</a>
<a id="contact" href="#contactSection">CONTACT</a>
</nav>
<div id="homeSection" class="sect
sectOne">
<div id="bigname">
<h1>
THOMAS OGBOURNE
</h1>
<button class="button button2 hvr-icon-hang hvr-fade">Begin</button>
</div>
</div>`
<div id="aboutSection" class="subSection">
<div class='content'>
<div class='visible'>
<p>
Hello I'm Tom:
</p>
<ul>
<li>Web Developer</li>
<li>Gamer</li>
<li>Student</li>
<li>Computer Guy</li>
</ul>
</div>
</div>
</div>
<div id="serviceSection" class="sect
sectTwo"></div>
<div id="gearSection" class="subSection2"></div>
<div id="portfolioSection" class="sect
sectThree"></div>
<div id="contactSection" class="smallsubSection">
<h2 style="margin-top:0;">
Email: *******************
</h2>
<h2>
Phone: **************
</h2>
</div>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/app.js"></script>
</body>
Is this what you wanted? :
https://jsfiddle.net/n3h3cm1x/
Basically your code is very messy and chaotic. there is something like this in there:
<button class="button button2 hvr-icon-hang hvr-fade">Begin</button>
</div>
</div>`
<div id="aboutSection" class="subSection">
<div class='content'>
Notice that ` symbol? that was the cause of the first break between divs.
the second break between divs is
top:-90px;
which you added to few sections at the bottom.
I'm making my portfolio and I thought it would be cool when you could see some nice animations when the page loads. only I don't know how to get the animations working. My idea was to make all the classes fade and easeIn slightly after each other so you would get a cool animation sequince when you have loaded the page.
My idea was:
Fade in the title_text in as the first one from left to right.
after that al the programming languages start fading in and ease in to the right from "javascript" to "php" to "mysql" to "css" and finaly "html".
I would like to make it flexible so that I can add more languages once I have learned them.
I'd like to learn from it myself so that I can make my own animations in the future.
for those interested this is my portfolio
image
thanks in advance!
<div class="animations">
<div class="html">
HTML
</div>
<div class="css">
CSS
</div>
<div class="php">
PHP
</div>
<div class="javascript">
JAVASCRIPT
</div>
<div class="mysql">
MySQL
</div>
</div>
CSS
span.mycalendar {
font-size: 0.38em;
line-height: initial;
font-family: arial;
display: block;
position: relative;
width: 7em;
height: 7em;
background-color: #fff;
margin: 0 auto;
border-radius: 0.6em;
border-style: solid;
border-width: 1px;
border-color: #CFAF3B;
overflow: hidden;
-webkit-backface-visibility: hidden;
-webkit-transform: rotate(0deg) skewY(0deg);
-webkit-transform-origin: 50% 10%;
transform-origin: 50% 10%;
}
title_text {
text-align: center;
width: 800px;
margin-left: auto;
margin-right: auto;
position: relative;
color: white;
z-index: 5;
margin-top: -420px;
font-size: 80px;
text-transform: uppercase;
font-family: league-gothic;
letter-spacing: 5px;
border: 10px solid white;
}
.animations .html {
font-family: league-gothic;
float: left;
margin-left: 200px;
top: 30px;
z-index: 10;
position: relative;
font-size: 100px;
color: white;
animation: 5s linear 2s infinite alternate;
}
.animations .css {
font-family: league-gothic;
float: right;
margin-right: 200px;
top: 100px;
z-index: 10;
position: relative;
font-size: 100px;
color: white;
}
.animations .php {
font-family: league-gothic;
float: right;
margin-right: 200px;
top: -270px;
z-index: 10;
position: relative;
font-size: 100px;
color: white;
}
.animations .javascript {
font-family: league-gothic;
float: left;
top: -330px;
margin-left: -100px;
z-index: 10;
position: relative;
font-size: 100px;
color: white;
}
.animations .mysql {
font-family: league-gothic;
float: right;
margin-right: -500px;
top: -150px;
z-index: 10;
position: relative;
font-size: 100px;
color: white;
}
li {
background-color: red;
text-align: center;
}
li > a {
display: inline-block;
vertical-align: middle;
background-color: blue;
padding: 10px;
}
.inner-wrapper {
display: inline-block;
vertical-align: middle;
}
span.mycalendar * {
display: block;
width: 100%;
font-size: 2.4em;
font-weight: bold;
font-style: normal;
text-align: center;
}
span.mycalendar strong {
position: absolute;
top: 0;
font-weight: normal;
padding-top: 0.06em;
color: #fff;
background-color: #CFAF3B;
box-shadow: 0 2px 0 #CFAF3B;
}
span.mycalendar span {
width: 100%;
font-size: 3.7em;
letter-spacing: -0.05em;
padding-top: 0.8em;
color: #2f2f2f;
}
ul {
list-style: none;
}
I've scaled it down a bit for the demo but I hope you get the idea
.animations .css,
.animations .html,
.animations .javascript,
.animations .mysql,
.animations .php {
font-family: league-gothic;
z-index: 10;
position: relative;
font-size: 20px;
color: #fff;
opacity: 0;
animation-name: fade-in;
animation-duration: 2s;
animation-fill-mode: forwards
}
body {
background: #777
}
.animations .html {
animation-delay: 0s
}
.animations .css {
animation-delay: 1s
}
.animations .php {
animation-delay: 2s
}
.animations .javascript {
animation-delay: 3s
}
.animations .mysql {
animation-delay: 4s
}
#-webkit-keyframes fade-in {
from {
opacity: 0
}
to {
opacity: 1
}
}
#keyframes fade-in {
from {
opacity: 0
}
to {
opacity: 1
}
}
<div class="animations">
<div class="html">
HTML
</div>
<div class="css">
CSS
</div>
<div class="php">
PHP
</div>
<div class="javascript">
JAVASCRIPT
</div>
<div class="mysql">
MySQL
</div>
</div>
Or make other weird and wonderful animations
.animations .css,
.animations .html,
.animations .javascript,
.animations .mysql,
.animations .php {
font-family: league-gothic;
z-index: 10;
position: relative;
font-size: 20px;
color: #fff;
transform: scale(0,0);
animation-name: pop-in;
animation-duration: 2s;
animation-fill-mode: forwards
}
body {
background: #777
}
.animations .html {
animation-delay: 0s
}
.animations .css {
animation-delay: 1s
}
.animations .php {
animation-delay: 2s
}
.animations .javascript {
animation-delay: 3s
}
.animations .mysql {
animation-delay: 4s
}
#keyframes pop-in {
from {
transform: scale(0,0);
}
to {
transform: scale(1,1);
}
}
<div class="animations">
<div class="html">
HTML
</div>
<div class="css">
CSS
</div>
<div class="php">
PHP
</div>
<div class="javascript">
JAVASCRIPT
</div>
<div class="mysql">
MySQL
</div>
</div>