What is best way to implement this? (sigh... stupid test...)

http://mayacove.com/misc/div.jpg

what’s best way to implement those lines inside the div?

divs of 1px width/height and positioning?

thank you…

(PS: the dialog to embed imgs here doesn’t work… after you select image and it shows in the dialog there’s no “ok” or any way to execute… only “clear list”…:wink:

shucks… never mind…

each button has to be centered w/in each square… so have to do divs… with (border-left, etc…)

thank you…

PS: how do I center buttons VERTICALLY? (obviously there are probs with vertical-align… one of the things I hate about CSS, it doesn’t implement vertical-align well, not in all browsers…)

thank you…

oh man…

they’re asking for the impossible here…

instructions are fixed height for the buttons, but not fixed width…

so I have to do dispaly:block, which gives them width 100%… how do I overwrite that w/o giving them a width?

I’M TIRED OF THESE STUPID TESTS… full of stupid trick demands…:frowning:
(the fact is these should be done w/no dimensions set…)

thank you…

Hi,

For ie8+ you can do this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.box {
	width:300px;
	height:300px;
	position:relative;
	border:1px solid #ccc;
	display:table;
}
.button {
	display:table-cell;
	vertical-align:middle;
	margin:0;
	text-align:center;
}
.button a {
	border:1px solid red;
	border-radius:5px;
	padding:5px 20px;
	text-align:center;
	display:inline-block;
	color:#000;
	text-decoration:none;
}
</style>
</head>

<body>
<h1>IE8+</h1>
<div class="box">
		<p class="button"><a href="#">Swap Vertical</a></p>
</div>
</body>
</html>

The display:table wrapper isn’t actually needed as the browser will construct it automatically around the display:table-cell element.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.button {
	width:300px;
	height:300px;
	border:1px solid #ccc;
	display:table-cell;
	vertical-align:middle;
	margin:0;
	text-align:center;
}
.button a {
	border:1px solid red;
	border-radius:5px;
	padding:5px 20px;
	text-align:center;
	display:inline-block;
	color:#000;
	text-decoration:none;
}
</style>
</head>

<body>
<h1>IE8+</h1>
<p class="button"><a href="#">Swap Vertical</a></p>
</body>
</html>

for this specific situation you could ALSO solve it using line height:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.box {
	width:300px;
	height:300px;
	border:1px solid #ccc;
	line-height: 300px;
	text-align:center;
}
 .box a {
	border:1px solid red;
	border-radius:5px;
	padding:5px 20px;
	display:inline-block;
	line-height: 1em;
	color:#000;
	text-decoration:none;
}
</style>
</head>

<body>
<h1>IE friendly</h1>
<div class="box"><a href="#">Swap Vertical</a> </div>
</body>
</html>

or you could also do this, using a pseudo element:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.box {
	width:300px;
	height:300px;
	border:1px solid #ccc;
	text-align:center;
}
.box:after {
	display:inline-block;
	height:100%;
	vertical-align: middle;
	content:'';
}

 .box a {
	border:1px solid red;
	border-radius:5px;
	padding:5px 20px;
	display:inline-block;
	vertical-align: middle;
	color:#000;
	text-decoration:none;
}
</style>
</head>

<body>
<h1>IE friendly</h1>
<div class="box"><a href="#">Swap Vertical</a></div>
</body>
</html>

see, piece of cake :slight_smile:

Note that in your first example Ray the space you have before the closing div is actually important to IE7 or it won’t work without it.

If we algamate line-height and display:table-cell methods then we have a robust method for IE8+ plus a method for IE7 all without extra mark up. It will also work for multiple lines. (The display:table-cell isn’t actually needed but will make the method more robust).