Why background-color doesn't work? - html

I am trying to set background-color for my footer, but it doesn't really change the background color.
This is what I have done so far.
In my code: I have wrapped the footer by body tag. That means the footer is inside the body tag.
.HTML:
<footer>
<div id="footer_box">
<p id="footer_text_left">
© 7 seas<br />
En del av 7seas Money Transfer KB<br />
F-skatt registrerat <br />
Org, Nr: <br />
SEB Företagskonto: <br />
BG:
</p>
<p id="footer_text_middle">
Besökadress:<br />
218 41 Bunkeflostrand<br />
Malmö, Sweden <br />
Web:
</p>
<p id="footer_text_right">
Tel: <br />
Mob: <br />
e-Mail:
</p>
</div>
</footer>
.CSS:
#footer_box{
border-top:2px solid #009933;
background-color:green;
}
#footer_text_middle, #footer_text_right{
font-size:12px;
font-family:Euphemia;
float: left;
width: 28%;
margin: 0 1%;
padding-bottom:15px;
}
#footer_text_left{
font-size:12px;
font-family:Euphemia;
float: left;
width: 31%;
margin-left: 120px;
padding-bottom:15px;
}

Add overflow: auto in your css:
#footer_box{
overflow: auto;
border-top:2px solid #009933;
background-color:green;
}
Here's a Fiddle.

You need to use a clearfix class on your footer_box element:
<div id="footer_box" class="clearfix">
And add this in css:
.clearfix:after {
content: " ";
display: block;
clear: both;
visibility: hidden;
height: 0;
}
Now it should work.

Just add the green color background to the #footer_text_left, #footer_text_middle, and #footer_text_right <p> tags.
#footer_box, #footer_text_left, #footer_text_middle, #footer_text_right{
border-top:2px solid #009933;
background-color:green;
}
#footer_text_middle, #footer_text_right{
font-size:12px;
font-family:Euphemia;
float: left;
width: 28%;
margin: 0 1%;
padding-bottom:15px;
}
#footer_text_left{
font-size:12px;
font-family:Euphemia;
float: left;
width: 31%;
margin-left: 120px;
padding-bottom:15px;
}
<div id="footer_box">
<p id="footer_text_left">
© 7 seas<br />
En del av 7seas Money Transfer KB<br />
F-skatt registrerat <br />
Org, Nr: <br />
SEB Företagskonto: <br />
BG:
</p>
<p id="footer_text_middle">
Besökadress:<br />
218 41 Bunkeflostrand<br />
Malmö, Sweden <br />
Web:
</p>
<p id="footer_text_right">
Tel: <br />
Mob: <br />
e-Mail:
</p>
</div>

Adding: overflow:auto; should do the trick
Not Related to your question, the use of <br/> is a bit frowned upon. it would be better if EACH sentence is stored into a <p> and given a class with a margin-bottom for example.
Just a thought though

Related

Why Do Inline Block Divs Behave Differently From Inline Block Buttons?

I tried to change the y-height of an inline button and realized that it doesn't work by setting a negative margin (transform would work though). Choosing a div instead of a button works, also wrapping the div inside a button. Where does this difference come from? I guess it has to do with baseline?
div, button {
box-sizing: border-box;
font-size: 0;
margin: 0;
padding: 0;
border: 0;
background: transparent;
}
.inline-offset {
display: inline-block;
width: 10px;
height: 10px;
margin-bottom: -5px;
border: solid 2px black;
}
Hello,<br />
dear
<div class="inline-offset"></div>
<br />
world!
<br />
<br />
Hello,<br />
dear
<button class="inline-offset"></button>
<br />
world!
<br />
<br />
Hello,<br />
dear
<button><div class="inline-offset"></div></button>
<br />
world!
[EDIT] Just in case it appears differently in some browsers, here's what it looks like to me. Second box is positioned as if no margin was present.
Recently I learned that whenever you set display: inline or inline-block you must be careful about any spaces or newlines that exist in front of the element.
I will be honest in saying that I don't know yet any official documentation about this behavior, but we all would appreciate any help to clarify it.
div, button {
box-sizing: border-box;
font-size: 0;
margin: 0;
padding: 0;
border: 0;
background: transparent;
}
.inline-offset {
display: inline-block;
width: 10px;
height: 10px;
border: solid 2px black;
}
Hello,<br />
dear <!--
--><div class="inline-offset"></div>
<br />
world!
<br />
<br />
Hello,<br />
dear <!--
--><button class="inline-offset"></button>
<br />
world!
<br />
<br />
Hello,<br />
dear <!--
--><button><div class="inline-offset"></div></button>
<br />
world!

Set width of all div elementes that are in same class as same

HTML
div.section{
/*border style code is skipped on this post*/
background-color: #99CCFF;
padding: 5px;
margin-top: 10px;
text-align: justify;
text-justify : auto;
overflow: hidden;
}
.topic{
/*border style code is skipped on this post*/
}
p{
overflow: hidden;
}
img{
float: right;
}
div#navi{
/*border style code is skipped on this post*/
margin: 5px;
width: 200px;
color: gray;
float: left;
}
div#navi h1{
text-align: left;
padding-left:10px;
}
div#navi ul{
margin-left: 0px;
}
<div id="body">
<div id="navi">
<h1>Links</h1>
<ul>
<li>Lab.</li>
<li>CSE # UNIV</li>
<li>W3Schools</li>
<li> Garden</li>
</ul>
</div>
<div class="section">
<h2><span class="topic">Cars</span>: 67 Shelby Mustang GT500 Convertible</h2>
<p>
<img src="67eleanorConv.jpg" alt="1967 shelby Mustang GT500 Convertible" title="1967 shelby Mustang GT500 Convertible" /> something..something..something..something..
</p>
</div>
<div class="section">
<h2><span class="topic">Sports</span>: Snowboarding</h2>
<p>
<img src="daaa.jpg" alt="Travis Rice Snowboard Jump" title="Travis Rice Snowboard Jump" /> something..something..something..something..something..
</p>
</div>
<div class="section">
<h2><span class="topic">Music</span>: Funk & Punk Rock</h2>
<p>
<img src="lesPaulBass.jpg" alt="Gibson Les Paul Bass" title="Gibson Les Paul Bass" /> something..something..something..something..
<br/>
<br/> something..something..something..something..
</p>
</div>
</div>
Code is so long,so i delete the part of border style in css.
I wrap div(id=nav) and div(id=section) into div(id=body)
I set a size of div that is at left side of nav div using "overflow="hidden".
but I can't set others.
The layout with a second column must still be a liquid layout -- that is, all parts of it should adjust in size accordingly when the browser size changes.
Here I post the link to the things I have and i want to:
Result that I wanna make
Current result of mine
The answer to your solution should be to set the navbar to absolute positioning. so that it will always extend the full height of the parent. Then you need to set position:relative to the parent div#body, Finally, the sections need to be adjusted to offset the navbar, so I do this by adding the CSS property margin-left:220px.
CSS:
div#navi {
/*border style code is skipped on this post*/
margin: 5px;
width: 200px;
color: gray;
position:absolute;
top:0px;
left:0px;
bottom:0px;
}
div#body {
position:relative;
}
div.section {
/*border style code is skipped on this post*/
background-color: #99CCFF;
padding: 5px;
margin-top: 10px;
text-align: justify;
text-justify: auto;
overflow: hidden;
margin-left:220px;
}
div#body {
position:relative;
}
div.section {
/*border style code is skipped on this post*/
background-color: #99CCFF;
padding: 5px;
margin-top: 10px;
text-align: justify;
text-justify: auto;
overflow: hidden;
margin-left:220px;
}
.topic {
/*border style code is skipped on this post*/
}
p {
overflow: hidden;
}
img {
float: right;
}
div#navi {
/*border style code is skipped on this post*/
margin: 5px;
width: 200px;
color: gray;
position:absolute;
top:0px;
left:0px;
bottom:0px;
}
div#navi h1 {
text-align: left;
padding-left: 10px;
}
div#navi ul {
margin-left: 0px;
}
<div id="body">
<div id="navi">
<h1>Links</h1>
<ul>
<li>Lab.</li>
<li>CSE # UNIV</li>
<li>W3Schools</li>
<li> Garden</li>
</ul>
</div>
<div class="section">
<h2><span class="topic">Cars</span>: 67 Shelby Mustang GT500 Convertible</h2>
<p>
<img src="67eleanorConv.jpg" alt="1967 shelby Mustang GT500 Convertible" title="1967 shelby Mustang GT500 Convertible" /> something..something..something..something..
</p>
</div>
<div class="section">
<h2><span class="topic">Sports</span>: Snowboarding</h2>
<p>
<img src="daaa.jpg" alt="Travis Rice Snowboard Jump" title="Travis Rice Snowboard Jump" /> something..something..something..something..something..
</p>
</div>
<div class="section">
<h2><span class="topic">Music</span>: Funk & Punk Rock</h2>
<p>
<img src="lesPaulBass.jpg" alt="Gibson Les Paul Bass" title="Gibson Les Paul Bass" /> something..something..something..something..
<br/>
<br/> something..something..something..something..
</p>
</div>

Make the background of a span inside of a div be full size using CSS

I am trying to make a gameserver console for our gameserver control panel.
Now a small styling issue I have is that every odd line needs to a have a slightly brighter background.
Instead of this:
I want this:
Code:
showLoading('gameTerminal_content', '32', 'html', '');
.gameTerminal_content_outputLine:nth-of-type(odd) { width:500px; background: #4C3C33; }
<div class="well-md" id="gameTerminal" style="background: #2A211C; height: 300px; max-width: 100%; overflow-y:scroll; font-family:'Courier New', Courier, monospace">
<p>
<span id="gameTerminal_content" style="color:#80FF80; width: 100%;">
<span class="gameTerminal_content_outputLine">Line 1</span><br /><br />
<span class="gameTerminal_content_outputLine">Line 2</span><br /><br />
<span class="gameTerminal_content_outputLine">Line 3</span><br /><br />
</span>
</p>
<!--<input type="text" name="gameTerminal_input" style="background: #4C3C33; float: left; color: #FFFFFF; width: 90%; border:none; position: absolute; bottom: 0; outline: none;" />-->
<div id="gameTerminal_scrollHeigth"></div>
</div>
You want your spans to be inline blocks if you want them to take up the width of the div. Just add:
.gameTerminal_content_outputLine { display: inline-block; }
Snippet:
showLoading('gameTerminal_content', '32', 'html', '');
.gameTerminal_content_outputLine:nth-of-type(odd) { width:500px; background: #4C3C33; }
.gameTerminal_content_outputLine {
display: inline-block;
}
<div class="well-md" id="gameTerminal" style="background: #2A211C; height: 300px; max-width: 100%; overflow-y:scroll; font-family:'Courier New', Courier, monospace">
<p>
<span id="gameTerminal_content" style="color:#80FF80; width: 100%;">
<span class="gameTerminal_content_outputLine">Line 1</span><br /><br />
<span class="gameTerminal_content_outputLine">Line 2</span><br /><br />
<span class="gameTerminal_content_outputLine">Line 3</span><br /><br />
</span>
</p>
<!--<input type="text" name="gameTerminal_input" style="background: #4C3C33; float: left; color: #FFFFFF; width: 90%; border:none; position: absolute; bottom: 0; outline: none;" />-->
<div id="gameTerminal_scrollHeigth"></div>
</div>
Couldn't you just add style that targets even lines using :nth-of-type(event) that is similar and slightly brighter than your current one which targets odd elements :
.gameTerminal_content_outputLine:nth-of-type(odd) {
width:500px;
background: #4C3C33;
}
.gameTerminal_content_outputLine:nth-of-type(even) {
width:500px;
background: #5D4D44;
}
Update
I hadn't realized you wanted to get rid of the explicit padding between each row of elements. Since the elements are <span> elements, you would want to set them to set them to display:block:
.gameTerminal_content_outputLine {
display: block;
}
which would render the content as seen in this example and demonstrated below :
You wants this ? (according to your pictures)
.gameTerminal_content_outputLine { display: block; width: 100%; }

CSS absolute position not being put in the correct location

I'm attempting to produce mailing list labels from a database connected to a website (yes, I could grab the list in some text format and import to something like Word... but ultimately I'm not going to be preparing the mailing so I want as few steps as possible in the process!). I've managed to get it working except for one part: the labels are not positioned correctly vertically.
I've looked at a number of questions on SO over the last few hours but none of the questions (or solutions) quite match what I've got.
I've defined 3 different paragraph classes for the 3 labels across the page (there's wierd gaps in the labels we've got for printing), with dimensions based on the label positions and size. Each label is a single paragraph with one of the 3 classes, and banks of labels sit inside a div representing the pages (these take into account the top and bottom margins of the pages).
Horizontally, it's working fine; vertically is another matter. Firebug is showing the paragraphs overlapping. I'm stumped as to what's going on.
Here's the CSS:
body
{
color: Black;
background-color: White;
font-family: "Times New Roman", Times, serif;
height: 100%;
margin: 0;
padding: 0;
font-size: 11pt;
}
p.print_label_left, p.print_label_right, p.print_label_middle
{
background: white;
position: absolute;
width: 5.4cm;
height: 1.43cm;
max-height: 1.43cm;
min-height: 1.43cm;
margin-left: 0.5cm;
margin-top: 1.48cm;
margin-right: 0.5cm;
margin-bottom: 0.5cm;
padding: 0.5cm;
top: 0;
border: none;
outline: solid 1px black;
}
p.print_label_left
{
left: 0.65cm;
}
p.print_label_middle
{
left: 7.3cm;
}
p.print_label_right
{
left: 13.95cm;
}
div.print_page
{
background: white;
position: relative;
padding: 0;
margin: 0;
left: 0;
top: 0;
width: 21cm;
height: 29.7cm;
border: none;
}
And here's a representative HTML sample (I can't give the real stuff due to privacy):
<body>
<div class="print_page" style="top:-1.33333333333cm;">
<p class="print_label_left" style="top:0cm;">A<br />
B<br />
C<br />
<br />
<br />
<br />
</p>
<p class="print_label_middle" style="top:0cm;">D<br />
E<br />
F<br />
<br />
<br />
<br />
</p>
<p class="print_label_right" style="top:0cm;">G<br />
H<br />
I<br />
<br />
<br />
<br />
</p>
<p class="print_label_left" style="top:2.43cm;">J<br />
K<br />
L<br />
<br />
<br />
<br />
</p>
<p class="print_label_middle" style="top:2.43cm;">M<br />
N<br />
O<br />
<br />
<br />
<br />
</p>
<p class="print_label_right" style="top:2.43cm;">P<br />
Q<br />
R<br />
<br />
<br />
<br />
</p>
</div>
</body>
The header defines a doctype (xhtml transitional 1.0) and I've played around with the max-height and min-height and putting extra lines in each paragraph to try to force it to have sufficient content to fill out the text, but no such luck.
When I print out the list, the outlines indicate the boxes are spaced at 2cm intervals not the required 2.43cm. And I'm fresh out of ideas of things to search for!
If it helps, I'm using Firefox 36 on a Windows 7 x64 machine but the server I'm running this on is a typical LAMP setup.
It's should work if i understand your question?
body
{
color: Black;
background-color: White;
font-family: "Times New Roman", Times, serif;
height: 100%;
margin: 0;
padding: 0;
font-size: 11pt;
}
p.print_label_left, p.print_label_right, p.print_label_middle
{
background: white;
width: 300px;
height: 100px;
margin-top: 10px;
padding: 0.5px;
top: 10px;
border: none;
outline: solid 1px black;
}
p.print_label_left
{
margin-left: 10px;
}
p.print_label_middle
{
margin-left: 150px;
}
p.print_label_right
{
margin-left: 300px;
}
div.print_page
{
background: white;
padding: 0;
margin: 5px;
left: 0;
top: 0;
width: 500px;
height: 100px;
border: none;
outline: solid 5px Red;
}
<div class="print_page">
<p class="print_label_left">A<br />
B<br />
C<br />
</p>
<p class="print_label_middle">D<br />
E<br />
F<br />
</p>
<p class="print_label_right">G<br />
H<br />
I<br />
</p>
<p class="print_label_left">J<br />
K<br />
L<br />
</p>
<p class="print_label_middle">M<br />
N<br />
O<br />
</p>

Basic CSS/HTML stacking up one DIV beneath another in a column

I realise this is so basic but cannot for the life of me work why I cannot get it working and have spent the last few hours trying everything
I need to the stack up DIVs so they form a big long column, one on top of the other. They are contained inside a JQuery scrollable DIV. I could absolute position all of the DIVS inside however there will be loads of them that change fairly regularly so would like a system where they automatically line if I have to insert a new one.
So I basically have one large Scrollable DIV. Inside this I have 2 other DIVs (#Release-Monsters & #Release-Insides) each containing 3 further DIVs. It is these 2 DIVs (#Release-Monsters & #Release-Insides) that I would like to stack on top of eachother to form a column. Once I have these 2 working I would to add about 50 or so more.
My CSS is this:
#All-Releases- {
position:absolute;
left:250px;
top:210px;
width:600px;
height:600px;
z-index:3;
}
/* Used to control height of scrollable div*/
p.ex
{
height:600px;
width:100px;
}
/* Vertical and horizontal scrollbar - one extra step required - add width of overview - overall width of scrolled content*/
#All-Releases- {
width: 500px;
}
#Release-Monsters {
position:static;
width:600px;
height:322px;
z-index:3;
}
#Artwork-Monsters {
position:absolute;
left:19px;
top:2px;
width:284px;
height:284px;
z-index:3;
}
#Release-Title-Monsters {
position:absolute;
left:322px;
top:0px;
width:284px;
height:284px;
color: #CCC;
font-size: 18px;
font-family: Century Gothic, Geneva, sans-serif;
letter-spacing: 2px;
text-align: justify;
z-index:3;
}
#Release-Info-Monsters {
position:absolute;
left:322px;
top:25px;
width:278px;
height:284px;
color: #CCC;
font-size: 12px;
font-family: Century Gothic, Geneva, sans-serif;
letter-spacing: 1px;
text-align: justify;
z-index:3;
}
#Release-Insides {
display:block;
width:600px;
height:322px;
z-index:3;
}
#Artwork-Insides {
position:absolute;
left:19px;
top:2px;
width:284px;
height:284px;
z-index:3;
}
#Release-Title-Insides {
position:absolute;
left:322px;
top:0px;
width:284px;
height:284px;
color: #CCC;
font-size: 18px;
font-family: Century Gothic, Geneva, sans-serif;
letter-spacing: 2px;
text-align: justify;
z-index:3;
}
#Release-Info-Insides {
position:absolute;
left:322px;
top:25px;
width:278px;
height:284px;
color: #CCC;
font-size: 12px;
font-family: Century Gothic, Geneva, sans-serif;
letter-spacing: 1px;
text-align: justify;
z-index:3;
}
and the HTML is this:
<div id="All-Releases-" class="default-skin demo">
<div id="Release-Monsters">
<div id="Artwork-Monsters"><img src="images/Release-Artwork/Monsters.jpg" width="284" height="284" /></div>
<div id="Release-Title-Monsters">MONSTERS</div>
<div id="Release-Info-Monsters">
1. Prologue<br />
2. Journey <br />
3. Candles <br />
4. Water <br />
5. Underwater <br />
6. Spores <br />
7. Campfire <br />
8. Dawn <br />
9. Attack <br />
10. Temple <br />
11. Encounter <br />
12. Monsters Theme
</div></div>
<div id="Release-Insides">
<div id="Artwork-Insides"><img src="images/Release-Artwork/Insides.jpg" width="284" height="284" /></div>
<div id="Release-Title-Monsters">INSIDES</div>
<div id="Release-Info-Insides">
1. The Wider Sun <br />
2. Vessel <br />
3. Insides <br />
4. Wire <br />
5. Colour Eye <br />
6. Light Through The Veins <br />
7. The Low Places <br />
8. Small Memory <br />
9. A Drifting Up <br />
10. Autumn Hill<br />
</div></div>
<p class="ex"></p>
</div>
<div id="All-Releases-" class="default-skin demo">
<div id="Release-Monsters">
<div id="Artwork-Monsters"><img src="images/Release-Artwork/Monsters.jpg" width="284" height="284" /></div>
<div id="Release-Title-Monsters">MONSTERS</div>
<div id="Release-Info-Monsters">
1. Prologue<br />
2. Journey <br />
3. Candles <br />
4. Water <br />
5. Underwater <br />
6. Spores <br />
7. Campfire <br />
8. Dawn <br />
9. Attack <br />
10. Temple <br />
11. Encounter <br />
12. Monsters Theme
</div></div>
<div id="Release-Insides">
<div id="Artwork-Insides"><img src="images/Release-Artwork/Insides.jpg" width="284" height="284" /></div>
<div id="Release-Title-Monsters">INSIDES</div>
<div id="Release-Info-Insides">
1. The Wider Sun <br />
2. Vessel <br />
3. Insides <br />
4. Wire <br />
5. Colour Eye <br />
6. Light Through The Veins <br />
7. The Low Places <br />
8. Small Memory <br />
9. A Drifting Up <br />
10. Autumn Hill<br />
</div></div>
<p class="ex"></p>
</div>
<script type="text/javascript">
$(window).load(function () {
$(".demo").customScrollbar();
});
</script
>
I looked over your HTML (not too bad except for list and <br>) and your CSS (overly complicated).
I cleaned things up a bit, you see the results at:
http://jsfiddle.net/audetwebdesign/42bgv/
Major CSS Fixes
Here is the CSS that I modified:
.All-Releases {
position: relative;
left: 20px;
top: 0px;
width:600px;
height: auto;
color: #CCC;
font-size: 12px;
font-family: Century Gothic, Geneva, sans-serif;
outline: 2px dotted blue;
}
.Release-Monsters {
position: relative;
width:600px;
height:322px;
outline: 2px dotted gray;
}
...
.Release-Insides {
position: relative;
width:600px;
height:322px;
outline: 2px dotted gray;
}
...
Originally, you declared absolute position for .All-Releases which caused all the panels to overlap each other, not good.
For Release-Monsters and Release-Insides, use position: relative so that the absolutely positioned elements stay where you expect. (Note: there are simpler ways to do this without using absolute positioning).
Finally, use class instead of id since id values are suppose to be unique.
Also, take advantage of CSS cascade and keep the font and color declarations in the top level rule, .All-Releases in this example.
Add a float property to each of the **s. For example:
#Artwork-Monsters {
position:absolute;
float:left;
left:19px;
top:2px;
width:284px;
height:284px;
z-index:3;
}
I would change your html to have unordered lists to start with to get rid of all the br tags that you have and may be able to get it a little neater.
JSFiddle
Example: http://jsfiddle.net/uk3BW/ <-- Doesn't have scroll bar
Example: http://jsfiddle.net/uk3BW/1/ <-- Has scroll bar
HTML
<ul id="Release-Info-Monsters">
<li> Prologue </li>
<li> Journey </li>
<li> Candles </li>
<li> Water </li>
<li> Underwater </li>
<li> Spores </li>
<li> Campfire </li>
<li> Dawn </li>
<li> Attack </li>
<li> Temple </li>
<li> Encounter </li>
<li> Monsters Theme </li>
</ul>
CSS
ul {
display:block;
background:#aeaeae;
padding:10px;
width: 250px;
list-style:none;
}
li {
display:block;
background:#eee;
padding: 10px 0;
width: 100%;
text-align:center;
}
li:last-child {
margin: 0;
}
li {
margin: 0 0 10px 0;}
li:hover {
background:#ccc;
}