Why this is happening? I need someone who can explain why divs not aligning properly?
HTML and CSS:
.horizontal-ruler {
width: 100%;
height: 25px;
line-height: 25px;
display: block;
font-size: 14px;
color: #373737;
}
.horizontal-ruler .ruler-unit {
width: 30px;
text-align: center;
display: inline-block;
line-height: 25px;
height: 25px;
vertical-align: middle;
}
.h-ruler-first-line,
.h-ruler-second-line {
width: calc(50% - 15px);
margin: 12px 0;
height: 1px;
background-color: #373737;
display: inline-block;
}
<div class="horizontal-ruler">
<div class="h-ruler-first-line"></div><!--
--><div class="ruler-unit">24"</div><!--
--><div class="h-ruler-second-line"></div>
</div>
https://jsfiddle.net/6xuvr6vw/1/
As you can see the .ruler-unit is not contained into the .horizontal-ruler.
You need to add vertical-align: middle to lines also
.horizontal-ruler {
width: 100%;
height: 25px;
line-height: 25px;
display: block;
font-size: 14px;
color: #373737;
}
.horizontal-ruler .ruler-unit {
width: 30px;
text-align: center;
display: inline-block;
line-height: 25px;
height: 25px;
vertical-align: middle;
}
.h-ruler-first-line,
.h-ruler-second-line {
width: calc(50% - 15px);
vertical-align: middle;
margin: 12px 0;
height: 1px;
background-color: #373737;
display: inline-block;
}
<div class="horizontal-ruler">
<div class="h-ruler-first-line"></div><!--
--><div class="ruler-unit">24"</div><!--
--><div class="h-ruler-second-line"></div>
</div>
You can achieve it with just 2 div elements using :after and :before pseudo elements.
.horizontal-ruler{
text-align: center;
overflow: hidden;
line-height: 25px;
font-size: 14px;
color: #373737;
height: 25px;
}
.horizontal-ruler .ruler-unit {
display: inline-block;
vertical-align: top;
position: relative;
padding: 0 10px;
}
.horizontal-ruler .ruler-unit:before,
.horizontal-ruler .ruler-unit:after {
background-color: #373737;
position: absolute;
margin-top: -1px;
width: 9999px;
height: 1px;
right: 100%;
content: '';
top: 50%;
}
.horizontal-ruler .ruler-unit:after {
right: auto;
left: 100%;
}
<div class="horizontal-ruler">
<div class="ruler-unit">24"</div>
</div>
A slightly different approach to your solution -this features a border bottom on the entire div and the a relative position of the text down over the line to give the appearance that it is two line separated by the text content. Could probably be better - just dodgied it up to show you an alternative that does not take much code to achieve the same effect.
.horizontal-ruler{
border-bottom:solid 1px #373737;
text-align:center;
}
.ruler-unit{
font-size:24px;
width:30px;
margin:0 auto;
padding: 0 10px;
position:relative;
top:14px;
background:white;
}
<div class="horizontal-ruler">
<div class="ruler-unit">24"</div>
</div>
Add vertical-align: middle to the lines:
.h-ruler-first-line, .h-ruler-second-line {
width: calc(50% - 15px);
margin: 12px 0;
height: 1px;
background-color: #373737;
display: inline-block;
vertical-align: middle;
}
fiddle: https://jsfiddle.net/udwffajo/
Related
I'm currently working on a website where I work with perfect squares and rectangles. These need to perfectly fit on mobile devices and laptop screens, tablets and so on. Therefore I want exactly now and be in control how much space every element is taking.
My problem: it goes about the light blue color, these div is taking 50% of the width and a height of 100%. Next I set the purple div to a height of 60% with a margin on top of 10% (so 70%), then I have the green div with a height of 30% which will bring the total to 100%. As you see in the example it isn't taking 100% but more than that.
I've red that the margin is calculated from the parent div (so the light-blue div I suppose), so I need to change my way of thinking-calculating I suppose but don't know how. Someone who can help me out?
.toegelatenDagWeek {
float: left;
background-color: yellow;
}
.verhoudingTijd {
float: right;
background-color: red;
}
.extraTijdDagWeek {
float: right;
background-color: silver;
}
.square-box{
position: relative;
width: 50%;
overflow: hidden;
}
.square-box:before{
content: "";
display: block;
padding-top: 50%;
}
.square-content{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
color: white;
text-align: center;
margin: 1%;
}
.vierkanttt{
width: 35%;
float:left;
text-align:center;
margin-left: 37.5%;
margin-right: 37.5%;
margin-top: 1%;
margin-bottom: 2%;
position: relative;
}
.vierkanttt-marges {
flex: 1;
margin: 1px 1px 1px 1px;
position: relative;
}
.inputTimeSmall {
background-color: #b721ff;
border: none;
border-radius: 0.5em;
padding: 15% 0% 20% 0%;
width:100%;
text-align:center;
font-size:0.8em;
}
input {
color: white;
}
.inputTimeSmall::placeholder {
color: white;
}
.inputTime:focus {
outline: none;
}
.inputTime {
background-color: #b721ff;
border: none;
border-radius: 0.5em;
padding: 15% 0% 20% 0%;
width:100%;
text-align:center;
font-size:4em;
color: white;
}
.gespeeldeTijdTitel {
color: white;
width: 100%;
padding-left: 5%;
float: left;
text-align: left;
text-decoration-line: underline;
//background: purple;
font-size: 1.5em;
padding-bottom: 3%;
padding-top: 3%;
background-color: blue;
}
.toegelatenTijdTitel {
background: blue;
height: 30%;
width: 100%;
position: relative;
}
.toegelatenTijdTitel div {
position: absolute;
top: 50%;
color: white;
text-decoration-line: underline;
transform: translateY(-50%);
margin-left: 5%;
font-size: 1.5em;
}
.testje {
width: 100%;
height: 70%;
background-color: black;
}
.spaceInputTimeSmall {
background-color: #21d4fd;
border-radius: 0.5em;
float:left;
width: 50%;
height: 100%;
}
.inputTimeMini {
width: 80%;
background-color: #b721ff;
font-size:2em;
height: 60%;
margin-top: 10%;
margin-left: 10%;
margin-right: 10%;
border-radius: 0.5em;
display: table;
}
.textBoxSmall {
height: 30%;
width: 80%;
background-color: green;
margin: 00% 10% 0% 10%;
vertical-align: center;
display: table;
}
.centerText {
display: table-cell;
text-align: center;
vertical-align: middle;
}
.boxtienprocent {
background-color: grey;
}
#container {
width: 90%;
height: 90%;
margin: 5%;
position: relative;
color: white;
}
<div class="square-box toegelatenDagWeek">
<div class='square-content '>
<div class="toegelatenTijdTitel">
<div>
toegelaten tijd
</div>
</div>
<div class="testje">
<div class="spaceInputTimeSmall">
<div class="boxtienprocent"></div>
<!--<input type="text" class="inputTimeSmall" id="inputHoursMaandag" name="maandagUren" placeholder="00" maxlength="3">-->
<div class="inputTimeMini" name="uren" id="DisplayToegelatenHours" ><div class="centerText">05</div></div>
<div class="textBoxSmall"><div class="centerText">uren</div></div>
</div>
<div class="spaceInputTimeSmall">
<!--<input type="text" class="inputTimeSmall" id="inputMinutesMaandag" name="maandagMinuten" placeholder="00" maxlength="2">-->
<div class="inputTimeMini" name="uren" id="DisplayToegelatenMinutes" ><div class="centerText">05</div></div>
<div class="textBoxSmall"><div class="centerText">minuten</div></div>
</div>
</div>
</div>
</div>
Instead of margins, you need to use padding, because padding is the space between the content and the border, meanwhile margin is the space outside the border. In your example, you used margins, so it pushed the rectangular outside.
I'm currently working in a final assignment for a class. I need to create a basic webpage (actually, the main goal of the assignment is to learn to use the local storage) but i got stuck on a very early stage of the making (i'm pretty novice in this). I've been using fixed divs for the main structure of the webpage and now idk how to add more content. i tried inherent position but everything went wrong.
the code: https://codepen.io/ipanonima/pen/WNbNeJm
html of the body:
<body>
<div class="main">
<div class="main-bar">
<div class="main-bar-container">
<div class="main-bar--logo">
<img src="./public/logo.png">
</div>
<div class="main-bar--info-container">
<div class="main-bar--info-container--buttons">
<div class="main-bar--info-container--buttons--b"><p>Botón</p></div>
<div class="main-bar--info-container--buttons--b"><p>Botón</p></div>
<div class="main-bar--info-container--buttons--b"><p>Botón</p></div>
</div>
<div class="main-bar--info-container--login">
<div class="main-bar--info-container--login--b"><p>login</p></div>
</div>
</div>
</div>
</div>
<div class="example-section">
<div class="example-section--pictures" id="ex1">
<div class="example-section--pictures-pic"><img src="./public/canada-example.jpg"></div>
<div class="example-section--pictures--overlay"><div class="overlay--text">canadá</div></div>
</div>
<div class="example-section--pictures" id="ex2">
<div class="example-section--pictures-pic"><img src="./public/mexico-example.jpg"></div>
<div class="example-section--pictures--overlay"><div class="overlay--text">méxico</div></div>
</div>
<div class="example-section--pictures" id="ex3">
<div class="example-section--pictures-pic"><img src="./public/eu-example.jpg"></div>
<div class="example-section--pictures--overlay"><div class="overlay--text">EE.UU.</div></div>
</div>
</div>
<div class="banner-sesion"></div>
</div>
</body>
and my css (which is getting really long)
*{
margin: 0;
padding: 0;
font-family: 'Montserrat', sans-serif;
}
input{
border: none;
border-bottom: 2px solid #74b5fa;
background-color: rgba(250, 167, 116, 0);
}
.box-session{
box-sizing: content-box;
position: relative;
background-image: linear-gradient(to top left,rgba(152, 116, 250,.1 ), rgba(250, 167, 116, 1));
width: 232px;
padding-left: 15px;
padding-right: 17px;
padding-top: 15px;
padding-bottom: 15px;
margin-top: 11%;
border-radius: 20px;
margin-left: calc(50% - 116px);
}
.session{
box-sizing: border-box;
position: relative;
width: 232px;
}
body{
background-color: #E2EBF8;
height: 100%;
width: 100%;
}
.relative{
position: relative;
height: 100%;
width: 100%;
}
.alto20{
height: 20%;
width: 100%;
}
.navBar{
position: fixed;
height: 100%;
width: 11%;
background-color: blue;
border-radius: 20px;
background-image: linear-gradient(#71AEFF, #4080FF);
}
.navBar--perfil{
position: relative;
float: left;
/* background-color: yellow; */
}
.navBar--photo{
position: relative;
margin-top: 25%;
/* background-color: blue; */
width: 100%;
height: 50%;
}
.navBar--photo img{
height: 30px;
width: 30px;
background-color: #FFFFFF;
border-radius: 5px;
margin-left: 40px;
}
.navBar--photo p{
color: #FFFFFF;
font-weight: bold;
font-size: 16px;
padding-left: 26px;
margin-top: 4px;
}
.navBar--opciones{
float: left;
width: 100%;
height: 60%;
}
.navBar--botones{
position: relative;
float: left;
width: 100%;
height: calc(100%/5);
}
.navBar--blanco{
position: relative;
height: 65px;
width: 65px;
/* background-color: green; */
margin-top: 3.5%;
margin-left: calc(50% - 52px);
box-sizing: border-box;
padding-top: 8px;
}
.navBar--blanco img{
height: 30px;
width: 30px;
margin-left: 19px;
}
.navBar--blanco p{
width: 100%;
color: #FFFFFF;
font-weight: bold;
font-size: 12px;
text-align: center;
}
.selected{
background-color: #FFFFFF;
border-radius: 20px;
color: #71AEFF;
}
.selected p{
color: #71AEFF;
}
.navBar--ayuda{
float: left;
/* background-color: green; */
}
.navBar--ayuda p{
position: relative;
background-color: #FFFFFF;
width: 70px;
height: 20px;
border-radius: 7%;
text-align: center;
color: #71AEFF;
font-weight: bold;
top: 75%;
left: 15%;
}
.main{
position: fixed;
height: 100%;
width: 55%;
background-color: #FFFFFF;
border-radius: 20px;
margin-left: 8%;
/* background-color: lightblue; */
}
.main--scroll{
position: absolute;
width: 90%;
/* background-color: pink; */
float: left;
overflow-y: scroll;
height: 95%;
overflow-y: auto;
overflow-x: hidden;
margin-top: 2.5%;
margin-left: 2.5%;
}
.lista ul{
float: left;
/* list-style-type: upper-roman; */
list-style-position: inside;
list-style-image: url('../public/man.png');
}
.tabla table{
border: 2px solid red;
border-collapse: separate;
}
.derecha{
position: fixed;
height: 100%;
width: 40%;
margin-left: 60%;
border-radius: 20px;
background-image: linear-gradient(#F3FAFC, #CCDBEF);
}
.ej{
background-color: greenyellow;
width: 100%;
height: 200px;
border: 1px solid black;
}
.noteblock{
width: 150px;
height: 150px;
background-color: #ff7190;
border-radius: 20px;
margin-left: 20px;
margin-top: 20px;
padding-top: 10px;
padding-left: 10px;
position: relative;
float: left;
}
.noteblock p{
color: white;
}
.noteblock h3{
color: white;
}
.boton{
margin-left: 20px;
margin-top: 20px;
position: relative;
}
thanks for all the patience
I think you may have misunderstood the fixed position. As it is, you can add more content perfectly well in your site: try setting .new { height: 2000px; background: orange;} and you'll see the orange wall does appear and the site scrolls. One thing that might be misleading you is because your header is also fixed, so any content you do add (an <h1> for example) is going to go under it.
In any case, because the banners are fixed, their position is relative to the screen, so they "go down" as you scroll, and they'll be in front of any content you add.
I don't understand what led you to set them fixed in the first place, but it's probably not a good idea. Try taking that out, give the ejemplo pictures a fixed height and let it scroll (try setting you header to sticky rather than fixed). When you're done with your homework, try researching CSS positions a bit more.
I want #cart to go to the right top of the page. When I add float, it goes down. Why? I'm putting there codes and images with and then without the float.
* {
margin: 0;
}
#fl {
background-color: #fff;
padding: 10px;
color: transparent;
font-size: 20px;
height: 60px;
margin-top: 100px;
text-align: center;
line-height: 60px;
width: 70%;
margin-left: auto;
margin-right: auto;
opacity: 0.8;
border-left: 5px solid black;
font-family: 'Nanum Gothic', sans-serif;
}
#log {
height: 60px;
margin-top: 2px;
}
#container {
width: 70%;
height: 70px;
background-color: rgba(111, 250, 171, 0.5);
box-shadow: 1px 1px 2px black;
margin-top: 20px;
display: flex;
justify-content: center;
margin-left: auto;
margin-right: auto;
flex-direction: row-reverse;
}
#cart {
font-size: 30px;
float: right;
height: 40px;
}
<div id="cart">CART</div>
<div id="fl">
<h1><span>BUY EXCLUSIVE ONDRIWATER TODAY</span></h1>
</div>
<div id="container">
<div class="greensale">
<span class="more">400ml</span> for just <span class="more">200$</span>
</div>
<div id="log">
<img src="logo.png" height="60" width="60" />
</div>
</div>
When you make the element floating the next one (id="fl") will become the first in-flow element and its top margin will collapse with the top margin of its the container (body). it's like you increased the top margin of the container by
margin-top: 100px; and since the floating element is placed considering this one the element will jump to its new position.
To avoid this, you need to avoid margin to collapse:
* {
margin: 0;
}
body {
padding-top:1px;
}
#fl {
background-color: #fff;
padding: 10px;
color: transparent;
font-size: 20px;
height: 60px;
margin-top: 100px;
text-align: center;
line-height: 60px;
width: 70%;
margin-left: auto;
margin-right: auto;
opacity: 0.8;
border-left: 5px solid black;
font-family: 'Nanum Gothic', sans-serif;
}
#log {
height: 60px;
margin-top: 2px;
}
#container {
width: 70%;
height: 70px;
background-color: rgba(111, 250, 171, 0.5);
box-shadow: 1px 1px 2px black;
margin-top: 20px;
display: flex;
justify-content: center;
margin-left: auto;
margin-right: auto;
flex-direction: row-reverse;
}
#cart {
font-size: 30px;
float: right;
height: 40px;
}
<div id="cart">CART</div>
<div id="fl">
<h1><span>BUY EXCLUSIVE ONDRIWATER TODAY</span></h1>
</div>
<div id="container">
<div class="greensale">
<span class="more">400ml</span> for just <span class="more">200$</span>
</div>
</div>
Adding background to the body will make you better see the issue. Comment/uncomment the floating property to see what is happening:
* {
margin: 0;
}
body {
background:red;
}
html {
background:#fff;
}
#fl {
background-color: #fff;
padding: 10px;
color: transparent;
font-size: 20px;
height: 60px;
margin-top: 100px;
text-align: center;
line-height: 60px;
width: 70%;
margin-left: auto;
margin-right: auto;
opacity: 0.8;
border-left: 5px solid black;
font-family: 'Nanum Gothic', sans-serif;
}
#log {
height: 60px;
margin-top: 2px;
}
#container {
width: 70%;
height: 70px;
background-color: rgba(111, 250, 171, 0.5);
box-shadow: 1px 1px 2px black;
margin-top: 20px;
display: flex;
justify-content: center;
margin-left: auto;
margin-right: auto;
flex-direction: row-reverse;
}
#cart {
font-size: 30px;
float: right;
height: 40px;
}
<div id="cart">CART</div>
<div id="fl">
<h1><span>BUY EXCLUSIVE ONDRIWATER TODAY</span></h1>
</div>
<div id="container">
<div class="greensale">
<span class="more">400ml</span> for just <span class="more">200$</span>
</div>
</div>
in your code #cart is top and right your page!
so, you could use absolute position like:
#cart {
font-size: 30px;
right: 0;
top:0;
height: 40px;
position:absolute;
}
instead of float: right do text-align: right. The float-style will align the #cartelement with #fl
Does anyone know why the image breaks onto a new line when the bubbles sides are constrained?
If I change the bubbles max-width to calc(100% - 70px) the image doesn't break although I get the last word on a new line, which also breaks the style.
body {
background: #f0f3f6;
}
.messages {
width: 100%;
margin-top: 65px;
margin-bottom: 70px;
padding-bottom: 15px;
}
.scrolling {
display: inline-flex;
flex: auto;
overflow-y: auto;
overflow-x: hidden;
}
.scrolled {
flex: 0 1 auto;
display: flex;
flex-flow: column nowrap;
justify-content: flex-end;
width: 100%;
height: 100%;
margin: 0 15px;
}
.message {
line-height: 1em;
display: block;
margin: 18px 0;
position: relative;
}
.message .image {
position: relative;
display: inline-block;
width: 25px;
}
.message img {
display: block;
width: 100%;
border-radius: 150px;
}
.message .bubble {
font-weight: 300;
position: relative;
vertical-align: text-top;
display: inline-block;
font-size: 0.9em;
padding: 12px 14px;
margin-top: -16px;
margin-left: 20px;
margin-right: 20px;
border-radius: 4px;
max-width: 100%;
}
.message .bubble::after {
content: '';
position: absolute;
top: 12px;
width: 0;
height: 0;
}
.message .time {
color: #838689;
font-weight: 500;
font-size: 0.7em;
position: absolute;
bottom: -1.9em;
width: 100%;
}
.message-left {
flex: 1;
align-self: flex-start;
}
.message-left .time {
left: 50px;
}
.message-left .bubble {
color: #343434;
background-color: #fff;
margin-left: 20px;
}
.message-left .bubble::after {
position: absolute;
left: -5px;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-right: 5px solid #fff;
}
.message-right {
flex: 0;
align-self: flex-end;
float: right;
}
.message-right .time {
text-align: right;
right: 50px;
}
.message-right .bubble {
color: #fff;
margin-right: 20px;
background-color: #0084ff;
}
.message-right .bubble::after {
position: absolute;
right: -5px;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-left: 5px solid #0084ff;
}
<div ref="messages" class="messages scrolling">
<div class="scrolled">
<div class="message message-left">
<span class="time">1 min ago</span>
<div class="image">
<img src="https://scontent-lht6-1.xx.fbcdn.net/v/t1.0-9/15492548_1291266807563287_6299338365875926813_n.jpg?oh=b2c7a59d1666247350753be9002e6884&oe=5AB71F93" />
</div>
<div class="bubble">
This message has the same problem.
</div>
</div>
<div class="message message-right">
<span class="time">1 min ago</span>
<div class="bubble">
A small comment.
</div>
<div class="image">
<img src="https://scontent-lht6-1.xx.fbcdn.net/v/t1.0-9/15492548_1291266807563287_6299338365875926813_n.jpg?oh=b2c7a59d1666247350753be9002e6884&oe=5AB71F93" />
</div>
</div>
<div class="message message-right">
<span class="time">1 min ago</span>
<div class="bubble">
A really long message, designed to be big enough to create a multi-line comment.
</div>
<div class="image">
<img src="https://scontent-lht6-1.xx.fbcdn.net/v/t1.0-9/15492548_1291266807563287_6299338365875926813_n.jpg?oh=b2c7a59d1666247350753be9002e6884&oe=5AB71F93" />
</div>
</div>
</div>
</div>
Original JSFiddle
The message element is display: block.
If you use display: flex instead, the image and text are forced to remain on a single line (because a default setting of a flex container is flex-wrap: nowrap).
revised demo 1
If you don't want the images to shrink, add flex-shrink: 0 to the items. (By default, flex items are set to flex-shrink: 1, allowing them to shrink so they don't overflow the container).
revised demo 2
So i'm trying to have a div with text appear on a parent div when a mouse hovers the parent, all was going well and good until I encountered a problem where the text ("VISIT") was no longer centering when the font size is changed to be larger.
.project-box {
width: 1000px;
background-color: white;
height: 350px;
margin: auto;
box-shadow: 0px 2px 5px 0px #737373;
}
.project-image {
width: 400px;
height: 260px;
margin-left: 30px;
background-color: #f1f1f0;
position: relative;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
}
.slidein-content {
display: none;
background-color: #ff9933;
z-index: 1;
width: 400px;
height: 50px;
position: absolute;
bottom: 0;
text-align: center;
}
.project-image:hover .slidein-content {
display: block;
}
.visit {
font-family: 'Montserrat', sans-serif, Arial;
color: white;
letter-spacing: 1px;
font-size: 2em;
<div class="project-box">
<div class="project-image">
<div class="slidein-content">
<p class="visit">VISIT</p>
</div>
</div>
</div>
As you can see, the text "VISIT" is aligned properly horizontally, but not vertically. Anyone know a solution?
Try using a <span> element instead of a <p> element. So modify your code to this:
<div class="project-box">
<div class="project-image">
<div class="slidein-content">
<span class="visit">VISIT</span>
</div>
</div>
</div>
That should help center it or at least get you in the right direction. I tested this on jsfiddle here. You may need to play around with the margin or padding a bit, but the problem you're having is because of the <p> element.
Set a line-height=0 on .visit
.project-box {
width: 1000px;
background-color: white;
height: 350px;
margin: auto;
box-shadow: 0px 2px 5px 0px #737373;
}
.project-image {
width: 400px;
height: 260px;
margin-left: 30px;
background-color: #f1f1f0;
position: relative;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
}
.slidein-content {
display: none;
background-color: #ff9933;
z-index: 1;
width: 400px;
height: 50px;
position: absolute;
bottom: 0;
text-align: center;
}
.project-image:hover .slidein-content {
display: block;
bottom:0;
}
.visit {
font-family: 'Montserrat', sans-serif, Arial;
color: white;
letter-spacing: 1px;
font-size: 2em;
line-height:0;
<div class="project-box">
<div class="project-image">
<div class="slidein-content">
<p class="visit">VISIT</p>
</div>
</div>
</div>
Add top:50%; and transform: translateY(-50%); to .slidein-content, erase the bottom:0 from it and add amargin: 0 to .visit (I don't know from where, but it has a 32px top- and bottom-margin, which you have to reset to 0 that way.)
.project-box {
width: 1000px;
background-color: white;
height: 350px;
margin: auto;
box-shadow: 0px 2px 5px 0px #737373;
}
.project-image {
width: 400px;
height: 260px;
margin-left: 30px;
background-color: #f1f1f0;
position: relative;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
}
.slidein-content {
display: none;
background-color: #ff9933;
z-index: 1;
width: 400px;
height: 50px;
position: absolute;
top:50%;
transform: translateY(-50%);
text-align: center;
}
.project-image:hover .slidein-content {
display: block;
}
.visit {
font-family: 'Montserrat', sans-serif, Arial;
color: white;
letter-spacing: 1px;
font-size: 2em;
line-height: 2em;
margin: 0;
}
<div class="project-box">
<div class="project-image">
<div class="slidein-content">
<p class="visit">VISIT</p>
</div>
</div>
</div>