Wierd Space Between Divs - HTML/CSS - html

Why does my code creates this wied spaces between divs.
HTML:
<div id="container">
<div id="header">
<p class="header_title">Theme Preview</p>
<p class="header_quote">Previewing Another Blog</p>
</div>
<div id="menu">
<ul>
<li></li>
<li></li>
</ul>
</div>
<div class="post">
<p class="post_title"></p>
<hr />
<p> <span class="post_date"></span> <span class="post_autor"></span> </p>
<div class="post_content">
</div>
<hr class="post_final" />
</div>
<div id="footer">
<p>Design by</p>
</div>
</div>
CSS:
body {
width:100%;
background-color:#C1C8D0;
height:auto;
}
#container {
margin:auto;
max-width:1600px;
width:100%;
height:auto;
}
#header {
background-color:#1B1C1E;
width:100%;
height:auto;
text-align:center;
}
.header_title {
padding-top:5%;
color:white;
font-family:Agency FB;
font-size:5em;
text-align:center;
}
.header_quote {
color:#EBEBEB;
font-family:Agency FB;
font-size:1em;
text-align:center;
padding-bottom:5%;
}
#menu {
background-color:white;
}
I already looked the CSS and I did not wrote any margin or something related to crate blank spaces.

I think it the p tag
p{margin: 0;}

It seems like you are not resetting the CSS, so each browser may render the CSS differently. To avoid that, I recommend to use a CSS reset file which need to be included before all CSS files. This file resets all the styles which may be applied by different browsers to a consistent baseline.
As a "hot-fix" you can still do this, but as mentioned it's more common to use a CSS reset.
Add margin: 0; to .header_quote and add following CSS rule
#menu > ul{
margin: 0;
}
Fiddle

Related

How to hyperlink a span that contains an image

HTML:
<footer>
<div class="foot">
<ul>
<span class="facebook"></span>
<span class="instagram"></span>
</ul>
</div>
</footer>
CSS:
.facebook {
display:block;
background-image:url("../images/facebook.png");
height:64px;
width:64px;
}
.instagram {
display:block;
background-image:url("../images/instagram.png");
height:64px;
width:64px;
}
.social {
height:64px;
width:64px;
display:inline-block;
position:relative;
margin:0 auto;
}
footer {
height:75px;
width:inherit;
bottom:0;
position:fixed;
}
.foot {
text-align:center;
}
The way I'm going about it could possibly be the wrong way. Any direction/advice would be great. I've tried using z-index and other properties but just nothing is working. I kinda wonder if it has to do with positioning/display inline.
A <span> should not contain any display:block elements anyway, it was designed for inline content although you can use it your way. Try use the <img> tag instead.
And wrap all your lines inside lis because you are using an ul
The links worked for me with no trouble.
You don't even need the span. You can move the class to the <a and have either 2 (social & facebook), or just make it to one css each with the inline and margin.
A span can have display:block property, but why you add span if you have your link ? I cleaned up your html :
HTML
<footer class="foot">
<ul>
<li></li>
<li></li>
</ul>
</footer>
and CSS
.social-facebook {
background-image:url("../images/facebook.png");
}
.social-instagram {
background-image:url("../images/instagram.png");
}
.social {
height:64px;
width:64px;
display:block;
margin:0 auto;
}
.foot {
height:75px;
width:inherit;
bottom:0;
position:fixed;
text-align:center;
}
I removed properties repetition and add a little bit of OOCSS :)

setting style for listbox

I created a listbox using nested div tags like so:
<div id="container">
<div id="scrollbox" >
<div id="content" >
<ul>
<li><img src="media/images/person.png" align="left"> Zero Users</li>
</ul>
</div>
</div>
<br><br><span id="status" ></span>
</div>
I have a javascript file that governs the listbox and a css file to set the styles:
#container{
background:white;
border: solid black 1px;
width:160px;
max-height: 150px;
margin:0px auto;
padding:20px 0;
}
#content{
background:white;
}
#scrollbox{
width:150px;
height:150px;
overflow:auto; overflow-x:hidden;
}
#status{background:#D8D8D8;}
I link to the external css file like so:
<link rel="stylesheet" href="media/css/jquery.listbox.css" type="text/css">
For the <ul> tag I wanted to eliminate the bullets that appear so I added the following to the css file:
#content ul {
list-style-type: none;
padding:0;
margin:0;
}
In FireFox and Chrome this styling for the <ul> tag was ignored. But if I setup a separate style on the webpage itself, it works as expected. Can someone explain why it works this way but not when I put it in the css file itself?

Position text to center of div left and right

I'm trying to create something that looks like this:
so far I have: http://jsfiddle.net/ePse6/
Without using something like: margin-top:-25px;, how can I position the Edit/Delete links to be on the right of the title (the part that says "iPhone" or "Android") and have both the title and links halfway between the borders?
Thanks!
just like most of answers, here i come with text-align:right and float:left .
I reduced code to minimal and plain CSS for your actual structure and to make it clear to you : http://jsfiddle.net/ePse6/7/
ul , a { /* basic reset we need */
padding:0;
margin:0;
color:gray;
text-decoration:none;
}
.mini > ul > li {
display:block;/* reset from list-item */
border-bottom:solid;
text-align:right;
overflow:hidden;/* wraps floatting element within */
}
.mini > ul > li> h3 {
float:left;
margin:0;
}
.mini > ul > li ul,
.mini > ul > li li {
display:inline-block;
}
Why not use something simple and really handy?
I have removed all of your messy code, and have created a new fiddle for you.
http://jsfiddle.net/afzaal_ahmad_zeeshan/ePse6/4/
I have used just a few lines of code, I have used a div and inside that, I have used 2 paragraphs to seperate each of them. Then inside that I used span element to seperate the right and left floating elements.
Using CSS I selected the classes and then styled them to get the desired input!
Here is the code:
<div>
<p>
<span class="left">Android</span><span class="right">Delete Edit</span>
</p>
<p>
<span class="left">iPhone</span><span class="right">Delete Edit</span>
</p>
</div>
CSS is as:
p {
border: 1px solid #333; // border that you wanted!
padding: 20px; // padding all around the element
padding-bottom: 40px; // padding at the bottom of the element
}
.left {
float: left; // making the elements float at the left
}
.right {
float: right; // floating elements at the right side
}
You can go to the fiddle page, and check for the design of the layout now. It was a simple thing. Hope its what you wanted.
This is without the lists. Just some CSS to do the trick: http://jsfiddle.net/Lg96p/
CSS:
.wrap{
width:100%;
border-bottom:solid 1px #666666;
margin-bottom:20px;
padding-bottom:10px;
}
.title{
font:bold 16px arial;
}
.fl{
float:left;
}
.fr{
float:right;
}
.lnk{
color:#6c6c6c;
display:inline-block;
text-align:right;
margin:0 10px 0 0;
text-decoration:none;
font:normal 14px arial;
}
HTML:
<div class="wrap fl">
<div class="title fl">iPhone</div>
<div class="fr"><a class="lnk" href="">Edit</a><a class="lnk" href="">Delete</a></div>
</div>
<div class="wrap fl">
<div class="title fl">Android</div>
<div class="fr"><a class="lnk" href="">Edit</a><a class="lnk" href="">Delete</a></div>
</div>
You should create two columns that fill the parent div. Make them both float:left; and for the right column you can align the text to the right text-align:right; or put two divs in it with float:right; for edit and delete.
Here is my fiddle: http://jsfiddle.net/ePse6/5/
Whatever you put into the columns or how to format it is up to you. But from here you have 2 columns independently next to each other.
If you want multiples of these stacked on top of each other i would change the container to a class and just add multiple of these containers with the columns to keep it tidy and readable. Like in this fiddle: http://jsfiddle.net/ePse6/6/
HTML:
<div class='container'>
<div class='leftCollumn'>
Iphone
</div>
<div class='rightCollumn'>
<a hreft="">Edit</a><a hreft="">Delete</a>
</div>
</div>
<div class='container'>
<div class='leftCollumn'>
Iphone
</div>
<div class='rightCollumn'>
<div class="button">Edit</div><div class="button">Delete</div>
</div>
</div>
CSS:
.container
{
width:600px;
margin:auto;
}
.leftCollumn
{
float:left;
width:400px;
background-color:#999;
}
.rightCollumn
{
float:left;
width:100px;
text-align:right;
background-color:#CCC;
}
.rightCollumn a
{
margin-left:10px;
margin-right:5px;
}
.button
{
margin-left:10px;
margin-right:5px;
background-color:#000;
color:#FFF;
float:right;
}

Css Inline doesn't work

I have a style and an index. I want to display a logo and a text in the same line but I can't. It display in a different line.
Here is the code:
index.php
<body>
<div id="headerbar">
Hello World
</div>
<div id="mainmenu-bar">
<div id="mainmenu-content">
<img src="http://www.conceptcupboard.com/resource-centre/wp-content/uploads/2013/04/recycle-logo.gif" height="75" width="75" style="margin-top:5px;">
<h1>Text that I don't see, because is down</h1>
</div>
</div>
<div id="content">
<h1 color="white">Hello World</h1>
</div>
</body>
and layout.css
#font-face{font-family: Maven Pro; src: url(../fonts/MavenPro-Regular.ttf);}
body{font-family:Maven Pro; background:#ECECEC; border:0; font-size:100%; vertical-align:baseline; margin:0; padding:0;}
#headerbar{height:30px; float:right; margin-right:20px; margin-top:5px;}
#mainmenu-bar{background:#4C84BC; width:100%; height:90px; overflow: hidden;}
#mainmenu-content{margin: 0 auto; width:1000px;}
You can test it here: http://jsfiddle.net/6WYk4/
Is Because you dont have inline-block the h1 , by default it display as block. try this:
#mainmenu-bar h1{
display:inline-block;
}
full example with vertical align:
http://jsfiddle.net/6WYk4/3/
<h1> is a block level element. Use a span instead :)
The reason they are not side by side is because they are block level elements. You need to add a float.
Also, inline styles are bad habits.
<img src="http://www.conceptcupboard.com/resource-centre/wp-content/uploads/2013/04/recycle-logo.gif" class="derp" />
<style type="text/css">
.derp {
height:75px;
width:75px;
margin-top:5px;
float:left;
}
</style>
Try this fiddle: http://jsfiddle.net/WurrZ/
#mainmenu-content img {float:left;}
#mainmenu-content h1 {float:left; width:600px;}
#content {clear:both;}
The image and the h1 need floats and the content needs to be cleared.
Add float:left; to the img's css

doctype html breaks layout

I am trying to replicate layout of html5doctor.com. I have IE8 installed here.
I am able to produce following output:
HTML
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="header">
</div>
<div id="nav">
<div id="navmenus">
<ul id="navmenulist">
<li class="menu" id="id1">
Home
<li class="menu">
Products
<li class="menu">
About Us
</ul>
</div>
</div>
<div id="content" >
<div id="article"></div>
<div id="sidebar"></div>
</div>
<div id="footer"></div>
</body>
</html>
CSS
/*I have added CSS Reset from http://meyerweb.com/eric/tools/css/reset/
Just deleted it for simplicity
*/
body
{
margin:0px;
padding:0px;
background-color:#E8E8E8;
text-align:center;
}
#header
{
background-color:#1F7ADB;
width:100%;
height:150px;
}
#nav
{
background-color:#1F7ADB;
width:100%;
text-align:center;
}
#navmenus
{
background-color:#14B3F7;
width:900px;
text-align:left;
}
li.menu
{
list-style:none;
display:inline;
height:35px;
padding:12px;
}
li.menu:hover
{
background-color:yellow;
}
li.menu a
{
text-decoration:none;
font-family:Arial;
font-size:18px;
}
#content
{
width:900px;
background-color:#ffffff;
height:1300px;
}
Notice li.menu:hover in above CSS. It is not working in IE8. So I added <!DOCTYPE html> as suggested at this thread.
It made hover work but now it broke the layout as follows:
I will like to get result that will work on IE8 first and then will like to learn work around that will work consistently in major (may not be in IE6) browser. And will glad to stick to CSS and HTML (no script). And above all will like to learn whats exactly wrong here.
Remove the text-align:center; from the body and use margin:auto for the block elements you want centered in the page..
The elements that require it are #navmenus and #content, so
#navmenus
{
background-color:#14B3F7;
width:900px;
margin:0 auto;
}
#content
{
width:900px;
background-color:#ffffff;
height:1300px;
margin:0 auto;
}
I would update the CSS for the content area to this:
#content
{
width:900px;
background-color:#ffffff;
height:1300px;
margin: 0 auto;
}
Using the margin will center this element, rather than trying to use text-align on the parent element.