I'm having trouble to get a div (or the text inside) to get on the vertical center. Normally I have no trouble getting a div to be a certain percentage from the top of a page, but in some weird way, the % part gets completely ignored.
Here's a Fiddle
It's a very dumbed down version of my project, but it still screws up with the margin-top.
The result I'm aiming for is having the big text in the vertical middle of the page at all times. I have a feeling I'm actually approaching this completely wrong.
HTML
<div class="col-md-12 top-text">
<span class="top-title">Billetten <br /> Tjekliste</span>
</div>
CSS
.top-text {
text-align: center;
color: #000;
height: 10px;
margin-top:50%;
}
span.top-title {
font-family: 'art', helvetica, arial, sans-serif;
font-size: 180px;
line-height: 1em;
display: inline-block;
-webkit-transform: rotate(-10deg) skew(-10deg, 0);
-moz-transform: rotate(-10deg) skew(-10deg, 0);
-ms-transform: rotate(-10deg) skew(-10deg, 0);
-o-transform: rotate(-10deg) skew(-10deg, 0);
transform: rotate(-10deg) skew(-10deg, 0);
}
What I usually do to center stuff vertically, is set their position to absolute, give it a top value of 50% and then drag them up again by translating them with a negative 50% (referred to their own width).
Here's a fiddle: http://jsfiddle.net/y1muc7gr/1/
span.top-title {
font-family: 'art', helvetica, arial, sans-serif;
font-size: 180px;
line-height: 1em;
display: block;
position: absolute;
top: 50%;
width: 100%;
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
-webkit-transform: rotate(-10deg) skew(-10deg, 0) translateY(-50%);
-moz-transform: rotate(-10deg) skew(-10deg, 0) translateY(-50%);
-ms-transform: rotate(-10deg) skew(-10deg, 0) translateY(-50%);
-o-transform: rotate(-10deg) skew(-10deg, 0) translateY(-50%);
transform: rotate(-10deg) skew(-10deg, 0) translateY(-50%);
}
You are forgetting to minus the half text's height.
http://jsfiddle.net/y1muc7gr/2/
.top-text {
text-align: center;
color: #000;
height: 10px;
margin-top:-180px;
position: absolute;
top : 50%;
}
is that what you want?
i have make this jsfiddle
add position:relative in top-title
and bottom:200px; change it according to your desired position
span.top-title {
position:relative;
font-family: 'art', helvetica, arial, sans-serif;
font-size: 180px;
line-height: 1em;
display: inline-block;
-webkit-transform: rotate(-10deg) skew(-10deg, 0);
-moz-transform: rotate(-10deg) skew(-10deg, 0);
-ms-transform: rotate(-10deg) skew(-10deg, 0);
-o-transform: rotate(-10deg) skew(-10deg, 0);
transform: rotate(-10deg) skew(-10deg, 0);
bottom:200px;
}
http://jsfiddle.net/y1muc7gr/5/
jsfiddle example
setting the container with table-cell you can give it the vertical align properties to center the text inside.
.top-text {
text-align: center;
color: #000;
height: 600px;
display: table-cell;
vertical-align: middle;
}
the only problem is that you should have a fixed height container.
Related
I want to display the text vertically. I've tried a tutorial that has text rotation. But it lefts space in right side. This is a code that I've to try and mixed with a little piece of code from the tutorial:
1. STYLE:
.list-group-item {
background: black;
}
.list-group {
text-align: center;
-webkit-transform-origin: 100% 0;
-moz-transform-origin: 100% 0;
-o-transform-origin: 100% 0;
transform-origin: 100% 0;
-webkit-transform: translate(-100%, 0) rotate(-90deg);
-moz-transform: translate(-100%, 0) rotate(-90deg);
-o-transform: translate(-100%, 0) rotate(-90deg);
transform: translate(-100%, 0) rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
2. LIST:
<ul class="list-group">
<li class="list-group-item">A</li>
<li class="list-group-item">B</li>
<li class="list-group-item">C</li>
<li class="list-group-item">D</li>
<li class="list-group-item">E</li>
</ul>
3. GOAL:
4. RESULT:
try this:
.verticaltext
{
position: relative;
padding-left:50px;
margin:1em 0;
min-height:120px;
}
.verticaltext-content {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
left: -40px;
top: 35px;
position: absolute;
color: #FFF;
text-transform: uppercase;
font-size:26px;
font-weight:bold;
}
your html structure will look like this:
<div class="verticaltext">
<div class="verticaltext_content">Test 12</div>
</div>
you will need to set an absolute position in order to rotate the element in this case <li></li>. follow this link for further clarification
I have a website with a header image ( 3279 x 710 px ) and I added a Ken Burns effect to it, but it seems like it is distorted. I made a fiddle with a test image, but i can't reproduce the distorted effect, however it has something to do with it's aspect ratio. The Image looks like it's pressed together.
Right now i tried to fix it with width set to auto and height to 100%, but I can't get it to work.
I made a fiddle here.
HTML
<div id="header-wrapper" class="wrapper">
<img src='http://eventzerz.com/wp-content/uploads/2018/03/Test-Logo-Small-Black-transparent-1.png' class='image-kenburns'>
<div id="header">
</div>
</div>
CSS
#header-wrapper {
background: transparent;
padding: 0;
}
.wrapper {
padding: 6em 0 9em 0;
}
.wrapper .title {
font-size: 0.9em;
width: 25em;
/*
height: 3.25em;
*/
height: 3.4em;
top: -3.25em;
line-height: 3.25em;
margin-bottom: -3.25em;
margin-left: -12.5em;
padding-top: 0.5em;
}
#header {
position: relative;
padding: 12em 0;
}
.homepage #header {
padding: 18em 0;
}
.image-kenburns {
overflow: hidden;
position: absolute;
z-index: -1;
animation: move 40s ease-in infinite;
height: 100%;
width: 100%;
}
#keyframes move {
0% {
-webkit-transform-origin: bottom left;
-moz-transform-origin: bottom left;
-ms-transform-origin: bottom left;
-o-transform-origin: bottom left;
transform-origin: bottom right;
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
50% {
transform: scale(1.2);
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
-o-transform: scale(1.2);
-moz-transform: scale(1.2);
}
100% {
transform: scale(1.0);
-ms-transform: scale(1.0);
-webkit-transform: scale(1.0);
-o-transform: scale(1.0);
-moz-transform: scale(1.0);
}
}
EDIT: I should mention that it's fine looking on desktop, what I need is the responsive version for tablets.
If you need your image to resize proportionally / keep the aspect ratio just add to your .image-kenburns class height: auto
This is my CSS and HTML.
div.musiclink {
position: relative;
}
a.music {
width: 258px;
height: 117px;
display: block;
background: deepskyblue url('MUSIC-cursive.png') center top no-repeat;
-webkit-transform: rotate(330deg);
-moz-transform: rotate(330deg);
-ms-transform: rotate(330deg);
-o-transform: rotate(330deg);
transform: rotate(330deg);
}
a.music:hover {
background-image: url('MUSIC-cursive-hover.png');
}
a.store {
position: relative;
left: 500px;
top: 100px;
width: 220px;
height: 110px;
display: block;
background: deeppink url('STORE-cursive.png') center top no-repeat;
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
transform: rotate(30deg);
}
a.store:hover {
background-image: url('STORE-cursive-hover.png');
}
<div class="musiclink">
</div>
<div class="storelink">
</div>
The thing is I positioned everything successfully when I used images instead of href links, but now nothing is working the way I want it to. I don't want the images/links to move when I resize the browser.
I've got a few lines of type set in a stylized h1 (type is skewed, underlined with border, etc). I'd like the h1 to appear over the top of the "bg-image" div class, but I'm having trouble. I'm new to using DIV structure.
.bg-image h1 {
display:inline-block;
font-size:48px;
font-family: "sofia-pro",sans-serif;
font-weight:900;
text-transform:uppercase;
color:#fff;
border-bottom:7px solid #fff;
padding-bottom:5px;
margin-top:4px;
-webkit-transform: rotate(-15deg) skew(-15deg, 0);
-moz-transform: rotate(-15deg) skew(-15deg, 0);
-ms-transform: rotate(-15deg) skew(-15deg, 0);
-o-transform: rotate(-15deg) skew(-15deg, 0);
transform: rotate(-15deg) skew(-15deg, 0);
text-transform: uppercase;
}
.bg-image {
position: relative;
}
.bg-image img {
display: block;
width: 100%;
background-size:cover;
max-width: 2000px; /* corresponds to max height of 450px */
margin: 0 auto;
}
<div class="bg-image">
<img src="http://s27.postimg.org/h12ymqn9v/Web_Hdr_Bground_1.jpg">
<h1>Nobody</h1>
<br>
<h1>Ever Says</h1>
<br>
<h1>Seize</h1>
<br>
<h1 class="skewed">Tomorrow.</h1>
</div>
You can use background-image on .bg-image class so you have more control.
Like this:
.bg-image h1 {
display:inline-block;
font-size:48px;
font-family: "sofia-pro",sans-serif;
font-weight:900;
text-transform:uppercase;
color:#fff;
border-bottom:7px solid #fff;
padding-bottom:5px;
margin-top:4px;
-webkit-transform: rotate(-15deg) skew(-15deg, 0);
-moz-transform: rotate(-15deg) skew(-15deg, 0);
-ms-transform: rotate(-15deg) skew(-15deg, 0);
-o-transform: rotate(-15deg) skew(-15deg, 0);
transform: rotate(-15deg) skew(-15deg, 0);
text-transform: uppercase;
}
.bg-image {
position: relative;
width: 500px;
height: 500px;
background: url('http://s27.postimg.org/h12ymqn9v/Web_Hdr_Bground_1.jpg') center;
background-size: cover;
}
<div class="bg-image">
<h1>Nobody</h1>
<br>
<h1>Ever Says</h1>
<br>
<h1>Seize</h1>
<br>
<h1 class="skewed">Tomorrow.</h1>
</div>
You have to play with position: relative and the distance in pixels you feel like for h1 to achieve your desired result. I just tried adding position: relative; and top: -450px;
.bg-image h1 {
display:inline-block;
font-size:48px;
font-family: "sofia-pro",sans-serif;
font-weight:900;
text-transform:uppercase;
color:#fff;
border-bottom:7px solid #fff;
padding-bottom:5px;
margin-top:4px;
-webkit-transform: rotate(-15deg) skew(-15deg, 0);
-moz-transform: rotate(-15deg) skew(-15deg, 0);
-ms-transform: rotate(-15deg) skew(-15deg, 0);
-o-transform: rotate(-15deg) skew(-15deg, 0);
transform: rotate(-15deg) skew(-15deg, 0);
text-transform: uppercase;
position: relative;
top: -450px;
}
.bg-image {
position: relative;
}
.bg-image img {
display: block;
width: 100%;
background-size:cover;
max-width: 2000px; /* corresponds to max height of 450px */
margin: 0 auto;
}
<div class="bg-image">
<img src="http://s27.postimg.org/h12ymqn9v/Web_Hdr_Bground_1.jpg">
<h1>Nobody</h1>
<br>
<h1>Ever Says</h1>
<br>
<h1>Seize</h1>
<br>
<h1 class="skewed">Tomorrow.</h1>
</div>
I am new to code and just saw this question. Have you tried the z-index? The z-index controls the z axis (up and down) of the webpage. Try putting z-index: -1 on css to make sure the picture will appear under the text on the webpage. Hope this helped!
I have an image and a div over it which is working as a wrapper for the image, I am trying to rotate a square div over let's say 45 deg. to give it a diamond like shape so actually it comes as the image is being cut in a diamond like shape.
The issue is when I rotate the div the image and other things in it also gets rotated than I have to rotate those images back let's say -45deg to bring them to original place.
This is doing above involved a lot of rotating which is almost un-necessary, plus it's really not that simple for me to get it right for images and text of different size etc.
If only I can work out something through which on the above div gets rotated and elements inside it remain like how they are it will be great.
Can anyone suggest anything please?
My markup is:
<div class="wrapper" id="01">
<a href="#">
<img src="image.gif" />
<span class="text" id="text01">Lorem Ispum </span>
</a>
</div>
CSS:
.wrapper {
-webkit-backface-visibility: hidden;
position: relative;
width: 300px;
height: 300px;
margin: 0 30px 0 0;
overflow: hidden;
float: left;
-moz-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-moz-transform-origin: center;
-webkit-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-webkit-transform-origin: center;
-o-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-o-transform-origin: center;
-ms-transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
-ms-transform-origin: center;
transform: matrix(-0.5,-0.5,0.5,-0.5,0,0);
transform-origin: center;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=-0.5,M21=-0.5,M12=0.5,M22=-0.5,SizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0.5,M21=-0.5,M12=0.5,M22=-0.5,SizingMethod='auto expand');
cursor: pointer;
}
.wrapper img {
width: 700px;
margin: -10px 0 0 -245px;
-moz-transform: rotate(135deg);
-moz-transform-origin: center;
-webkit-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
-webkit-transform-origin: center;
-o-transform-origin: center;
-ms-transform-origin: center;
transform: matrix(-0,-0,0,-0,0,0);
transform-origin: center;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=-0,M21=-0,M12=0,M22=-0,SizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=-0,M21=-0,M12=0,M22=-0,SizingMethod='auto expand');
}
span.text {
background-color: rgba(255,255,255,0.7);
-webkit-transform: rotate(180deg);
margin: -475px 0 0 -1px;
float: left;
width: 296px;
height: 42%;
z-index: 100;
position: relative;
padding: 4px;
display: none;
font-size: 1.2em;
}