Click here to Skip to main content
15,942,897 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Center text vertically inside a div Pin
_Flaviu16-Mar-23 3:40
_Flaviu16-Mar-23 3:40 
GeneralRe: Center text vertically inside a div Pin
_Flaviu17-Mar-23 1:25
_Flaviu17-Mar-23 1:25 
AnswerRe: Center text vertically inside a div Pin
Richard MacCutchan17-Mar-23 1:47
mveRichard MacCutchan17-Mar-23 1:47 
GeneralRe: Center text vertically inside a div Pin
_Flaviu17-Mar-23 3:51
_Flaviu17-Mar-23 3:51 
GeneralRe: Center text vertically inside a div Pin
Richard MacCutchan17-Mar-23 4:20
mveRichard MacCutchan17-Mar-23 4:20 
GeneralRe: Center text vertically inside a div Pin
_Flaviu17-Mar-23 4:22
_Flaviu17-Mar-23 4:22 
GeneralRe: Center text vertically inside a div Pin
Richard MacCutchan17-Mar-23 4:30
mveRichard MacCutchan17-Mar-23 4:30 
AnswerRe: Center text vertically inside a div Pin
Jeremy Falcon20-Mar-23 8:43
professionalJeremy Falcon20-Mar-23 8:43 
Just a heads up, floats are not needed here at all. Anyway, the vertical align property is for inline containers. A div by default is a block level element so it's ignored. To see what I mean check out the examples on MDN and W3Schools.

With that being said, there are much, much better ways to do this. If you want to vertically center without having to use explicit heights, the recommended way these days is to just use flexbox. There are a ton of other techniques like negative margins, line height, etc. too but flexbox should be something to master anyway. So, no time like the present.
HTML
<div style="width:100%;height:100px;background-color:#aaddee;border-style:solid;border-width:1px;display:flex;align-items:center;justify-content:center;">
  <div style="background-color:#ffeaae;border-style:solid;border-width:3px;">
    Tuesday 2023-03-20
  </div>
</div>
Be aware that inline styles should be avoided. Only using them here to match your example.
Jeremy Falcon

GeneralRe: Center text vertically inside a div Pin
_Flaviu21-Mar-23 1:30
_Flaviu21-Mar-23 1:30 
GeneralRe: Center text vertically inside a div Pin
Jeremy Falcon21-Mar-23 4:01
professionalJeremy Falcon21-Mar-23 4:01 
QuestionWhich language should I use out of javascript or php? Pin
Member 1595298015-Mar-23 22:39
Member 1595298015-Mar-23 22:39 
AnswerRe: Which language should I use out of javascript or php? Pin
Richard MacCutchan15-Mar-23 22:43
mveRichard MacCutchan15-Mar-23 22:43 
GeneralRe: Which language should I use out of javascript or php? Pin
Member 1595298015-Mar-23 22:58
Member 1595298015-Mar-23 22:58 
GeneralRe: Which language should I use out of javascript or php? Pin
Richard MacCutchan15-Mar-23 23:15
mveRichard MacCutchan15-Mar-23 23:15 
GeneralRe: Which language should I use out of javascript or php? Pin
Member 1595298016-Mar-23 2:47
Member 1595298016-Mar-23 2:47 
AnswerRe: Which language should I use out of javascript or php? Pin
Jeremy Falcon20-Mar-23 8:45
professionalJeremy Falcon20-Mar-23 8:45 
GeneralRe: Which language should I use out of javascript or php? Pin
Member 1595298024-Mar-23 0:20
Member 1595298024-Mar-23 0:20 
GeneralRe: Which language should I use out of javascript or php? Pin
Jeremy Falcon24-Mar-23 4:15
professionalJeremy Falcon24-Mar-23 4:15 
GeneralRe: Which language should I use out of javascript or php? Pin
Member 1595298026-Mar-23 0:04
Member 1595298026-Mar-23 0:04 
GeneralRe: Which language should I use out of javascript or php? Pin
Jeremy Falcon27-Mar-23 4:31
professionalJeremy Falcon27-Mar-23 4:31 
QuestionEnumerate a div pattern in html page Pin
_Flaviu14-Mar-23 0:28
_Flaviu14-Mar-23 0:28 
AnswerRe: Enumerate a div pattern in html page Pin
jsc4214-Mar-23 4:24
professionaljsc4214-Mar-23 4:24 
GeneralRe: Enumerate a div pattern in html page Pin
_Flaviu14-Mar-23 5:45
_Flaviu14-Mar-23 5:45 
GeneralRe: Enumerate a div pattern in html page Pin
_Flaviu14-Mar-23 22:08
_Flaviu14-Mar-23 22:08 
AnswerRe: Enumerate a div pattern in html page Pin
Jeremy Falcon20-Mar-23 9:15
professionalJeremy Falcon20-Mar-23 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.