Welcome to WebmasterWorld Guest from 50.17.16.177

Forum Moderators: not2easy

Message Too Old, No Replies

cannot centre text in div's and the div's themselves

     
6:28 am on Dec 31, 2013 (gmt 0)

New User

joined:Sept 18, 2013
posts:30
votes: 0


I am trying to get some text centered in a set of div's I have evenly spaced across the browser but cant work out how. anyone assist?

[jsfiddle.net...]

also in Chrome and firefox I cannot centre the 4 divs like I can in internet explorer, anyone assist here as well in fixing this?
6:46 am on Dec 31, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12704
votes: 244


text-align: justify;
-ms-text-justify: distribute-all-lines;
text-justify: distribute-all-lines;

:: sitting on hands ::
7:12 am on Dec 31, 2013 (gmt 0)

New User

joined:Sept 18, 2013
posts:30
votes: 0


cool, that has aligned the text but in chrome and firefox still remains the issue of not centering the div's evenly across the page as it expands
9:53 am on Dec 31, 2013 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 2, 2003
posts: 948
votes: 4


Hi there TheIceman5,


try it like this...


<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">

<title>untitled document</title>

<style>
.container {
border:2px dashed #444;
height:125px;
}
.box1,.box2,.box3,.box4 {
float:left;
width:15%;
height:100%;
margin-right:13.33%;
text-align:center;
}
.box4 {
margin-right:0;
}
.box1,.box3 {
background:#ccc
}
.box2,.box4 {
background:#0ff
}
</style>

</head>
<body>

<div class="container">
<div class="box1">1 1 1 1 1 1</div>
<div class="box2">2 2 2 2 2 2</div>
<div class="box3">3 3 3 3 3 3</div>
<div class="box4">4 4 4 4 4 4</div>
</div>

</body>
</html>


birdbrain
12:37 pm on Dec 31, 2013 (gmt 0)

New User

joined:Sept 18, 2013
posts:30
votes: 0


you da man, thanks for that, works perfectly in all 3 browsers.
5:28 pm on Dec 31, 2013 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 2, 2003
posts: 948
votes: 4


No problem, you're very welcome. ;)


birdbrain
9:18 pm on Dec 31, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12704
votes: 244


cool

Er, I was quoting from the link you posted.