inline-block vertical positioning issue - html

Hi I am developing a Resume in HTML. I am having problem with my inline-block as both the div that are required to be placed with each other using inline-block are not showing the expected results one of the div slightly moved downwards.
It seemed to be some sort of positioning issue but I am unable to figure it out.
The div are concerned with S-boxes and L-boxes style
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=UTF-8/>
<title>HELLO STRICT</title>
<style>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section
{
display: block;
}
h1{
color: #906;
font-family: "Arial Black", Gadget, sans-serif;
margin-bottom: 0px;
}
h4{
margin-bottom: 0px;
margin-top: o;
}
<style>
time
{
font-style: italic;
}
li {
padding-left: 0px;
text-indent: 0em;
}
div.S-boxes{
width: 200px;
height: 150px;
background-color: #E8E8E8;
display: inline-block;
text-align: right;
}
div.L-boxes{
width: 500px;
height: 150px;
background-color: #E8E8E8;
display: inline-block;
}
p.inbox{
margin-top:16px;
}
</style>
</head>
<body>
<h1>Muhammad Qais</h1>
<div>
<ul style="list-style: none; padding-left: 0px;">
<li>Village Sooj Bahadar, P.O. Mandra.
<li>Tehsil Gujarkhan
<li>District Rawalpindi
<li>Pakistan
</ul>
<table>
<tr>
<td>
<img src="Telephone-icon-1-.gif" width="27" height="27">
</td>
<td>
: +92-347-9714967
</td>
</tr>
<tr>
<td>
<img src="letter_closed.png" width="27" height="27">
</td>
<td>
: muhammadqais32#yahoo.com
</td>
</tr>
</table>
</div>
<div class="S-boxes">
<h4>Objective</h4>
</div>
<div class="L-boxes">
<p class="inbox">Seeking a challenging opportunity where I will be able to utilize my strong organizational skills, educational background, and ability to work well with people, which will allow me to grow personally and professionally. I am self-motivated and able to work both independently and as collaborative team member.</p>
</div>
</body>
</html>

display: inline-block; helps us here to render two square gray boxes next to each other. Awesome, right? However, with varying content, we need to add the property vertical-align: top to make sure everything is aligned to the top.
div.S-boxes{
width: 200px;
height: 150px;
background-color: #E8E8E8;
display: inline-block;
vertical-align:top;
text-align: right;
}

div.S-boxes{
background-color:#FFF;
width:20px;
height:20px;
display:inline-block;
border:solid black 1px;
}
div.L-boxes{
background-color:#FFF;
width:20px;
height:20px;
display:inline-block;
border:solid black 1px;
}

Related

There is blank space present at the top of website page

I am creating a web page. Even though i have added margin:0px and padding:0px still some blank space is present at the top of my web page. here is my css code for body section.Any solutions?Thanx in advance..
<html >
<head>
<style>
html {
margin: 0;
padding: 0;
}
#navR
{float:right;
margin-right:0px;
}
#mR{
float: right;
}
.bodyl{
height: 100%;
background-color: #F8FADE;
font-family: Arial;
font-size:15px;
margin:0px;
top: -22px;
clear: both;
}
.local{
background-color:#DEB887;
margin-left:0px;
margin-right:0px;
margin-top:0px;
margin-bottom:0px;
padding:0px;
width:100%;
vertical-align: baseline;
}
.heading{
font-size: 250%;
color:#5B3205;
margin-top:10px;
font-style: oblique;
}
</style>
</head>
<body>
<div class="local">
<p id="mR"><strong>My name</strong></p>
<h3 id="navR"> <a>logout</a> </h3>
<h1 class="heading">My space</h1>
</div> </br>
</body>
</html>
You are using a <h1> tag. This text has a default margin set by the browser. You can set a margin-top: 0px in your .heading class. That will fix the problem.
edit: In your case you should replace margin-top: 10px with margin-top: 0px
Please also set margin to 0 on your html attribute
body, html {
margin: 0;
padding: 0;
}
Then it should work perfectly for you, as it does for me. It could also be possible that you have a child attribute that has a certain margin and so it could lead to that white space.

HTML5's !doctype is messing up my styles

I'm currently working on some simple gallery, that should show thumbnails of a fixed size of 148px.
When I specify <!doctype html> at the very beginning of the file it messes up my style so that it looks like on this picture.
Without this line (I guess the browser is working in HTML4 mode then) it looks correct:
Take a look at the file by yourself: http://ablage.stabentheiner.de/2013-08-10_gallery.html
New file version: http://ablage.stabentheiner.de/2013-08-10_gallery2.html same file with different doctype: http://ablage.stabentheiner.de/2013-08-10_gallery2_html4.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Gallerie</title>
<base target="Hauptframe">
<style>
body {
background-color: #CCFFCC;
background-image:url(../background.gif);
}
table {
border:none;
border-spacing:0;
}
img {
border:none;
}
A:hover {
color: #FF0000;
font-weight: bold
}
.imagefloat {
border: medium solid #FFF;
float: left;
margin-top: 0px;
margin-right: 16px;
margin-bottom: 20px;
margin-left: 0px;
}
.nowrap {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
font-size: 16px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.nowrapline2 {
font-size: 12px;
}
.nowrapline3 {
font-size: 10px;
}
.error {
font-weight: bold;
color: #F00;
}
.caption_cell {
background-color: #FFF;
width: 148px;
height: 80px;
}
</style>
</head>
<body>
<div class="imagefloat">
<table>
<tr>
<td><img src="http://placehold.it/148x148" width="148" height="148" alt=""></td>
</tr>
<tr class="caption_cell">
<td>
<p class="nowrap">Title</p><p class="nowrap nowrapline2">Subtitle</p><p class="nowrap nowrapline3">Copyright</p>
</td>
</tr>
</table>
</div>
<div class="imagefloat">
<table>
<tr>
<td><img src="http://placehold.it/148x148" width="148" height="148" alt=""></td>
</tr>
<tr class="caption_cell">
<td>
<p class="nowrap">Title</p><p class="nowrap nowrapline2">Subtitle</p>
</td>
</tr>
</table>
</div>
</body>
The solution is simple enough. Images by default are handled as inline objects. For inline rendering, a minimum vertical clearance between rows is generally required and this is added by the browser for better readability. To remove this additional clearance try applying 'display: block' to these images.
Okay, your problem here's simple: you aren't using valid HTML5. The first thing you should always check is that your code validates as well-formed HTML, which yours doesn't. After that, check your CSS too; but just be aware that if the problem is that your site displays more nicely in HTML4 mode than HTML5 mode, then that's not a bug, that means that you've done something wrong writing your code.
Your first step here is to fix all of the glitches which the W3C validator has pointed out; if that doesn't fix the problem, then take another look at your CSS.

How come my form input sometimes moves when I refresh the page?

On a page that I'm designing I have a form with one input of type text. Normally, this form and input render properly in my browser, Chrome, but occasionally, it renders about 20 pixels to the left of where it is supposed to be. When I refresh the page, it goes back to the original, correct place.
I have only tested in Chrome so far, so this isn't a cross-browser issue (it happens in the same browser). Is there anything wrong with my code below?
Here's my HTML code:
<!DOCTYPE htmls>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Test Site</title>
</head>
<body >
<div id="supercontainer" class="style1">
<img class="floater" src="top.jpg" alt="Top" />
<img class="floater" src="left.jpg" alt="Left" />
<div id="content">
<p id="theText">
Welcome. Please type a username.
</p>
<form id="prompt">
<div><input type="text" name="promptLine" autocomplete="off" id="promptLine" onkeypress="return submitenter(event);" value="% " /></div>
</form>
</div>
<img class="floater" src="right.jpg" alt="Right" />
<img class="floater" src="bottom.jpg" alt="Bottom" />
</div>
Here's my CSS code:
#supercontainer {
margin: 0 auto;
width: 900px;
display: block;
}
img.floater {
display: inline;
float: left;
}
#content {
background-color:black;
display: inline;
float: left;
padding-left:5px;
padding-right:5px;
min-height:458px;
max-height:458px;
min-width: 803px;
max-width: 803px;
color: lime;
}
#theText {
text-align:left;
margin-bottom:0;
margin-top:0;
line-height: 0.3;
font-family:"Courier New", Courier, monospace;
}
#prompt {
position: fixed;
top: 470px;
}
#promptLine {
width: 100%;
background-color: black;
color: lime;
border: none;
outline:none;
}
Try closing your BODY and HTML tags? Also, doctype "htmls"?

help needed with doctype

I'm having trouble with a test site's design. When I'm opening my html page with IE, without my doctype line, it renders just the way I like it, but not in FF (because of the way it interprets padding, among other things). When I add the doctype line, the page gets squeezed to a height of about 230px. My intention is to set the height to the maximum page height.
Here are my files:
* index.html *
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="stylesheet.css" />
<!--[if IE]>
<style type="text/css">
body {
text-align: center;
/* Remove padding: */
padding: 0;
}
#container {
/* Mind the box model in IE.. */
height: 100%;
}
</style>
<![endif]-->
</head>
<body>
<!--[if IE]><div id="container"><![endif]-->
<div class="container">
<div class="header">
<h1>Logo</h1>
</div>
<div class="nav widget-header ">
<!-- main nav -->
<div class="nav-button state-default " ><img src="a.jpg" alt="a" /></div>
<div class="nav-button state-default " ><img src="b.jpg" alt="b" /></div>
<div class="nav-button state-default " ><img src="c.jpg" alt="c" /></div>
<div class="nav-button state-default " ><img src="d.jpg" alt="d" /></div>
<div class="nav-button state-default " ><img src="e.jpg" alt="e" /></div>
</div >
<div class="content">
<!--content area-->
<p>content</p>
</div>
<div class="footer">
<!-- footer -->
<p>© Copyright</p>
</div>
</div>
<!--[if IE]></div><![endif]-->
</body>
</html>
* stylesheet.css *
/* reset */
html, body, div, span,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
img, ins, kbd, q, s, samp,
sbutton_cl, strike, strong,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
}
.body{
line-height: 1;
text-align: center;
}
.widget-header {
background:#333333 url(images/bg-state-default.png) repeat-x scroll 50% 50%;;
border:1px solid #333333;
color:#FFFFFF;
font-weight:bold;
}
.state-default {
background: #CC0000 url(images/button-state-default.png) repeat-x scroll 50% 50%;
border:1px solid #333333;
color:#FFFFFF;
font-weight:bold;
font-size: 1em;
outline-color:-moz-use-text-color;
outline-style:none;
outline-width:medium;
}
.container {
border: 1px solid #999999;
margin: 0 auto;
width: 800px;
height: 100%;
background-color:#999999;
}
.header {
border: 1px solid #999999;
height:10%;
margin-top: 0;
padding: 10px;
}
.nav{
border: 1px solid #999999;
height:10%;
margin-top: 2%;
padding: 10px;
text-align: center;
vertical-align: middle;
}
.nav-button {
float: left;
height: 100%;
margin-left: 3px;
overflow: hidden;
width: 150px;
}
.content{
border: 1px solid #999999;
height:60%;
margin-top: 4%;
padding: 10px;
background-color:#FFFFFF;
}
.footer{
border: 1px solid #999999;
height:10%;
margin-top: 4%;
padding: 10px;
text-align: center;
vertical-align: middle;
background-color: #FFFFFF;
}
What I'm ultimately trying to do is a design with fixed width and percentage-based height, where child divs are also percentage-based positioned to their parents ( I believe this is the correct way to deal with different screen resolutions ).
I'll be very grateful if anyone can help me with this.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Sandbox</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
*{margin:0;padding:0;}
#wrapper { background:red; }
html,body{height:100%;}
#wrapper{min-height:100%;}
</style>
<!--[if IE 6]><style>
#wrapper { height:100%; }
</style><![endif]-->
</head>
<body>
<div id=wrapper>
<p>Hello from JS Bin</p>
<p id="hello"></p>
</div>
</body>
</html>
It isn't clear which version of Explorer you're using (apart from 6), but min-height is read as height by some versions...
However - this is the professional (and easiest way) way to build HTML/CSS:
validate your HTML (important, as invalid HTML can confuse browsers in unpredictable ways!)
get it working and looking how you like in FF;
add conditional comments for IE6 and (if necessary) IE7 and 8.
In IE 6 remember that padding etc. is not added to a box, so will decrease any width or height. Also, some elements without certain CSS properties, e.g. no specific width or height (or auto), do not trigger 'haslayout' in IE.
That may not have solved the problem directly, but I hope it helps pin things down!
Though I appreciate his effort, meder's answer was helpful, but incomplete since i want to have a percentage-based design. Dave's answer is more like guidelines. The best solution to my problem is something similar to this:
http://matthewjamestaylor.com/blog/perfect-3-column.htm
Now my problem is solved, thank you for your help.

CSS div width in IE8

I'm very new to html and css so feel free to critique any bad practices you see in the code below...
I am trying to create a centered column that's 800 pixels across and the banner will be resized to 800 pixels. When view this page in chrome or firefox it looks great. When I view it in IE8 the font is huge, there is a giant empty spot on the right side of the banner all the way down to the bottom, and the size of the "container" will not change no matter what I do in the css file.
CSS:
body {
font-family: Arial;
font-size: small;
background-color: #FFFFFF;
background-image: url(../images/victorianBackground.jpg);
background-position: top;
background-repeat: repeat;
color: #000000;
}
#container {
margin: -10 auto;
background-color: #D3CDBA;
text-align: left;
}
html>body #container {
width: 800px;
min-height:800px;
padding: 0 0px;
}
#banner {
width:800px;
}
#banner img {
width:800px;
padding:45 0px;
}
#content {
width:500px;
padding: 15px;
background-color: transparent;
}
/* Navigation */
#navigation ul {
list-style-type: none;
width: 800px;
margin: 0;
padding: 0;
}
#navigation li {
float: left;
background-color: #D3CDBA;
}
#navigation li:hover {
float: left;
color: #4676A4;
background-color: #D3CDBA;
}
#navigation a {
font-weight: bold;
text-decoration: none;
color: #000000;
display: block;
padding: 5px;
}
#navigation a:hover {
font-weight: bold;
text-decoration: none;
color: #992332;
}
#content a {
color:teal;
}
HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Park Avenue Neighborhood Association</title>
<meta name="keywords" content="Park Avenue Neighborhood Association Syracuse New York"/>
<link rel="stylesheet" type="text/css" href="../styles/style1.css">
</head>
<body>
<div id="container">
<div id="banner">
<img src="../images/banner.jpg" id="banner">
<br/>
</div>
<div id="navigation">
<ul>
<li>Home</li>
<li>History</li>
<li>Houses</li>
<li>Local Business</li>
<li>Events</li>
<li>Contacts</li>
</ul>
</div>
<div id="content">
<h2>Content Header 1 </h2>
<p>Awesome Content </p>
<h2>Content Header 2 </h2>
<p>Awesome Content </p>
</div>
</body>
</div>
</html>
There are multiple issues I see with your source. Non-exhaustive list:
1) You need a doctype. Otherwise, browsers will render items in a non-standard way.
Example:
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2) You have a <div> ending after the </body> tag. This is invalid.
Fix:
<p>Awesome Content </p>
</div>
</div>
</body>
</html>
3) You don't need the extra <br> in <div id="banner">.
Fix:
<div id="banner">
<img src="../images/banner.jpg" id="banner">
</div>
4) Now, if you want <div id="container"> to be centered and have a width of 800px, try the following.
Centering code that goes in your css (replaces existing):
body { text-align: center; }
#container {
text-align: left;
width: 800px;
margin: auto;
}
5) For your font-size declaration, you're using small. This will behave unpredictably. Instead, consider using either em or px for font size.
Font size with em:
body { font-size: 100%; line-height: 1.125em; }
#container { font-size: 0.875em; }
Font size with px:
body { font-size: 16px; line-height: 1.125em; }
#container { font-size: 12px; }
First thing I saw, you need to add this to the very first line of your HTML to force IE to render in standards mode, instead of quirks mode:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
In regard to centering the banner, try adding the following:
in body selector:
text-align: center;
in banner:
margin-right: auto;
margin-left: auto;
In regard to font size try using em or % sizing.
Other than that just tackle the problems one at a time, fine tune the details incrementally. Throwing in everything all at once will only create confusion - chances are it wont work as expected, but will frustrate you.