This question already has answers here:
How do I vertically align text in a div?
(34 answers)
Closed 8 years ago.
Here you can show an example of my code : Jsfiddle
<div id="gameTimeBar-holder">
<div id="gameTimeBar"></div>
<div class="progressBarText">Actions : 852 minutes</div>
#gameTimeBar-holder{width:200px;height:15px;background:grey; position:absolute; top:45px; left:5px;}
#gameTimeBar{width:0;height:100%;background:purple;}
.progressBarText{position:absolute;z-index:10;top:0;left:0;width:100%;text-align:left; color: white;}
How can i vertical center my text in the div progressBarText ?
add line-height to your text
try this:
.progressBarText{
position:absolute;
z-index:10;
top:0;
left:0;
width:100%;
line-height:15px;
text-align:left;
color: white;
}
DEMO
Related
This question already has answers here:
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
How can I vertically align elements in a div?
(28 answers)
Closed 5 months ago.
I have the following code, but I can not align the different span elements within my container so it looks correctly.
here is an image with what I'm trying to achieve: https://ibb.co/f2sy5YY
.container{
font-weight:bold;
font-size:10px;
display:inline-block;
position:relative;
width:100%;
}
.hash{
color:dodgerblue;
}
.text{
font-size:24px;
}
.numbers{
background-color:dodgerblue;
color:#ffffff;
border-radius:4px;
padding:2px;
}
<div class="container">
<span class="hash">#</span>
<span class="text">hello</span>
<span class="numbers">14</span>
</div>
This question already has answers here:
Center one and right/left align other flexbox element
(11 answers)
Center flex items with one at the end of the row [duplicate]
(3 answers)
Closed 3 years ago.
I have a div that contains two divs inside. First div has to be aligned to the left , second div has to be
aligned to the center relatively parent div.Please could you help me .Here is my jsfiddle : https://jsfiddle.net/armakarma/zy3L9a7h/
html
<div class='test'>
<div class='logo'>logo</div>
<div class='title'> title </div>
</div>
css
.test{
display:flex;
border:1px solid black;
}
.title{
margin: 0 auto;
}
.logo{
width:160px;
border:1px solid red;
}
This question already has answers here:
How do I vertically center text with CSS? [duplicate]
(37 answers)
Closed 6 years ago.
I have an h3 with a height of 100%. Therefore the height is unknown. How can I center the text within itself? For the sake of the example, I have given the parent fixed dimensions but this is not the case. I have tried using vertical align but that doesn't work, I believe I may need to change the display to do that?
I don't want to center the text within its parent, I know various methods to do this. I want to know if it is possible to vertically center it within itself. The text needs to be 100% in both dimensions so that the link fills the parent div.
.unknowndimensions{
height:300px;
width:300px;
}
.unknowndimensions h3{
height:100%;
width:100%;
background:#f7f700;
text-align:center;
}
<div class="unknowndimensions">
<h3>Title</h3>
</div>
Using table method,
.unknowndimensions{
height:300px;
width:300px;
}
.unknowndimensions a{
display:table;
width:100%;
height:100%;
}
.unknowndimensions h3{
display:table-cell;
vertical-align:middle;
background:#f7f700;
text-align:center;
}
<div class="unknowndimensions">
<h3>Title</h3>
</div>
This question already has answers here:
CSS technique for a horizontal line with words in the middle
(34 answers)
Closed 8 years ago.
Tried everything, with ul's... div's... but it doesn't appear how it should do.
The main div has margin 0 auto. The main div is 1030px width.
I bet it's a stupid thing...
Demo Fiddle
HTML
<div><span>Things to Know</span></div>
CSS:
div{
text-align:center;
}
div:after{
position:relative;
display:block;
border-top:1px solid grey;
top:-10px;
height:1px;
content:'';
}
div span{
background:white;
position:relative;
z-index:1;
}
This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 9 years ago.
I'm trying to horizontally center a div-block containing images (playing cards placed there by Javascript), but somehow it doesn't work (images are still left-aligned). Here's the HTML:
<div id="dealerarea">
<div id="dealercards">
<!--Images by Javascript-->
</div>
</div>
And here's the CSS:
#dealerarea{
position:absolute;
width:100%;
height:96px;
top:15px;
}
#dealercards{
display: block;
margin-left: auto;
margin-right: auto;
}
What i'm doing wrong? Thanks in advance!
Edit: I can't give a fixed "width" to inner div, because it changes every time (depending on the number of card images).
You need to give your #dealercards a width and margin:0 auto ;
#dealercards
{
display: block;
margin:0 auto;width:200px;
}
DEMO HERE