CSS - Displaying boxes on separate rows - css

Im trying to display my posts on serperate rows, but they keep overflowing the bounds of the container. I tried setting the width of of parent to a minimum, but it still overflows. heres a link to my blog site
www.darealistmedia.com
There you can see my problem. And heres the my CSS file. "Main" is the container im trying to keep them in.
* {
margin:0px;
padding:0px;
}
h1 {
font:bold 20px Tahoma;
}
h2 {
font:bold 14px Tahoma;
}
header, section, footer, aside, nav, article, hgroup {
display:block;
}
body {
width:100%;
display:-webkit-box;
-webkit-box-pack:center;
}
.holder {
max-width:1000px;
margin:15px 0;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-box-flex:1;
}
header {
background:yellow;
border:3px solid black;
padding:auto;
/*20*/
}
.navigation {
border:3px solid black;
background:blue;
color:white;
padding:10px;
text-align:center;
}
.navigation div {
display:inline-block;
}
.new_div {
display:-webkit-box;
-webkit-box-orient:horizontal;
}
.main {
text-align:center;
border:4px solid orange;
-webkit-box-flex:1;
margin:20px;
padding:20px;
}
.right-sidebar {
border:1px solid red;
width:220px;
margin:20px;
margin: background:#66cccc;
}
footer {
text-align:center;
padding:20px;
border-top:2px solic green;
}
/*Post Styles*/
.postSection {
display:-webkit-box;
-webkit-box-orient:horizontal;
width:800px;
overflow:scroll;
}
.postWrapper {
border:2px solid red;
padding:5px;
margin:11px;
width:270px;
height:270px;
}
.postTitle {
background-color:#303030;
font-size:28px;
font-weight:bold;
font-family:Trajan Pro;
color:white;
padding:5px;
}
.postContent {
background:#c7c7c7;
}
.postTabs {
text-align:center;
background-color:#202020;
float:left;
color:white;
padding:5px;
}
.day {
font-size:30px;
}
.linkList {
float:right;
}
What am I doing wrong?

This behaves exactly as it is supposed to. You told the postWrapper to have a height of 270px, and it does, even if the content is larger. You could use overflow: hidden; to hide the extra content, but this will cut off your content mid-sentence. Possibly better to replace height: 270px; with min-height: 270px;:
.postWrapper {
border:2px solid red;
padding:5px;
margin:11px;
width:270px;
min-height:270px;
}

Related

Footer Layout Issues

I'm trying to figure out why this footer is acting unusual. If you notice in the demo the HR tag in the location section is being pushed to the bottom of the page. Which is changing the layout. Also i'm trying to get the Facebook Icon to float:left so that it will be to the left of the HR tag within the "Network With Us section." My CSS looks fine to me, but this is the first time i've used the section tags for html5.
Also i'm having troubles applying a background-color or a margin-top:50px to my #footer.It's as if the #footer is ignoring me.
Here is my Demo
#footer {
background-color:#95643d;
width:100%;
margin:30px 0px 0px 0px;
clear:both;
}
#footer h3 {
font-family: 'Dancing Script', cursive;
font-weight:700;
color:#FFF;
font-size:2em;
}
#footer hr {
width:60%;
float:left;
height:4px;
background-color:#FFF;
}
#footer p {
margin:0px;
padding: 0px;
color:#FFF;
font-family: 'Arimo', sans-serif;
}
#footer_logo {
width:25%;
float:left;
background-color:#95643d;
}
#footer_logo img {
margin:20px 0px 0px 20px;
}
#footer_network {
width:25%;
float:left;
background-color:#95643d;
}
#footer_contact {
width:25%;
float:left;
background-color:#95643d;
}
#footer_network img {
float:left;
}
}
#footer_location {
width:25%;
float:left;
background-color:#95643d;
}
You can use this CSS:
/* Footer */
#footer {
background-color:#95643d;
width:100%;
}
#footer h3 {
font-family: 'Dancing Script', cursive;
font-weight:700;
color:#FFF;
font-size:2em;
text-align: center;
}
#footer hr {
width:100%;
float:left;
height:4px;
background-color:#FFF;
}
#footer p {
margin:0px;
padding: 0px;
color:#FFF;
font-family: 'Arimo', sans-serif;
text-align: center;
margin-bottom: 10px;
}
#footer_logo {
width:100%;
float:left;
background-color:#95643d;
}
#footer_logo img {
margin: 10px auto;
display: block;
}
#footer_network {
float:left;
background-color:#95643d;
width: 33%;
}
#footer_contact {
width: 33%;
float:left;
background-color:#95643d;
}
#footer_network img {
margin: 0 auto;
display: block;
}
#footer_location {
display: inline-block;
background-color:#95643d;
width: 34%;
}
Also i'm having troubles applying a background-color or a margin-top:50px to my #footer.It's as if the #footer is ignoring me.
When you have floats, the parent element collapses, so you have to clear the floats. One often-used technique is the clearfix class. Applied to your element it would look like this:
#footer:after {
content: "";
display: table;
clear: both;
}
I have a fiddle with cleaner code that you can use parts of it, or the whole thing, at your convenience. https://jsfiddle.net/r3ruzLL2/2
https://jsfiddle.net/r3ruzLL2/2/embedded/result/
EDIT: For the Facebook logo, an easy solution is to use a negative margin-top.
Add this rule:
section{
overflow:hidden;
}
Here you go, this seems to be fixing your problem: http://jsfiddle.net/weissman258/kpo4y108/10/.
Here are the things I added.
#footer {
display:inline-block;
}
#footer_network {
position:relative;
}
#footer_network a {
position:absolute;
left:0;
}
#footer_location {
display:inline-block;
}
As well as removing:
#footer_network img {
float:left;
}
Edit: Your first line on location seemed to be aligned right, so made another change to fix it:
#footer p {
clear:left;
}
Here is a fiddle for you https://jsfiddle.net/kpo4y108/6/ . You have break's in your html that you don't need. You have background's in different div's, which you don't need if you are only going to have one color. Let me know if you have any questions.
<div id="footer">
<section id="footer_logo">
<img src="http://nuskinprinting.com/atticstash/images/as_logo.png" />
</section>
<section id="footer_network">
<a><img src="http://nuskinprinting.com/atticstash/images/facebook_icon.png" /></a>
<h3>Network With Us</h3>
<hr />
</section>
<section id="footer_contact">
<h3>Contact Us</h3>
<hr />
<p> Vivian#advancedlitho.com<br />(972)999-9999 </p>
</section>
<section id="footer_location">
<h3>Location</h3>
<hr />
<p> Orange Circle Antique Mall<br />118 South Glassell Street<br />Orange, CA 92866<br />(714)538-8160<br />Mon. 10 a.m. - 4:45 p.m.<br />Tues - Sat 10 a.m. - 5:45 p.m.<br />Sun. 11 a.m. - 5:45 p.m. </p>
</section>
</div>
css:
/* Footer */
#footer {
background-color:black;
width:100%;
margin:30px 0px 0px 0px;
clear:both;
float:left;
}
#footer h3 {
font-family: 'Dancing Script', cursive;
font-weight:700;
color:#FFF;
font-size:1.5em;
margin:0px;
padding:0px;
}
#footer hr {
width:60%;
float:left;
height:4px;
}
#footer p {
margin:0px;
padding: 0px;
color:#FFF;
font-family: 'Arimo', sans-serif;
float:left;
word-wrap:break-word;
}
#footer_logo {
width:25%;
float:left;
}
#footer_logo img {
margin:20px 0px 0px 20px;
max-width:80%;
}
#footer_network {
width:25%;
float:left;
}
#footer_contact {
width:25%;
float:left;
}
#footer_network img {
float:left;
width:25px;
height:25px;
margin: 5px 5px 0 0;
}
#footer_location {
width:25%;
float:left;
}

Can't horizontal center div in parent

I have some divs set up as navigation buttons and I have put all the buttons into a div and then put that div into another "holder" div. the problem is that I can't seem to center the div that holds the buttons.
I've tried to add margin:0 auto but it doesn't seem to do anything:
HTML:
<div class="navholder">
<div class="nav">
<div class="button1"><div class="triangle"></div></div>
<div class="button2"><div class="triangle"></div></div>
<div class="button3"><div class="triangle"></div></div>
<div class="button4"><div class="triangle"></div></div>
<div class="button5"><div class="triangle"></div></div>
<div class="button6"><div class="triangle"></div></div>
</div>
</div>
CSS:
.navholder {
width:950px;
height:350px;
background-color:grey;
}
.nav {
position:relative;
bottom:0px;
margin:0 auto;
}
.button1, .button2, .button3, .button4, .button5, .button6 {
width:120px;
height:35px;
background-color:rgb(204,204,204);
margin-left:5px;
margin-right:5px;
display:inline-block;
float:left;
}
.button1:hover > .triangle, .button2:hover > .triangle, .button3:hover > .triangle, .button4:hover > .triangle, .button5:hover > .triangle, .button6:hover > .triangle{
display: block;
}
.button1:hover, .button2:hover, .button3:hover, .button4:hover, .button5:hover, .button6:hover{
background-color:#B7939B;
}
.triangle {
position:relative;
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 15px solid #B7939B;
top:-15px;
left:0;
right:0;
margin:0 auto;
display: none;
}
Heres a Fiddle of my code.
Add width to your .nav class:
.nav {
position:relative;
bottom:0px;
margin:0 auto;
width:780px;
}
You can try with this:
.navholder {
text-align:center;
}
.nav {
display:inline-block;
}
Your demo http://jsfiddle.net/S6BVL/3/
Specify a width for .nav that is large enough for the 5 buttons. It is defaulting to 100% of its container, 950px. Fiddle: http://jsfiddle.net/S6BVL/2/
Try this demo , i added text-align:center to .navholder and width:800px to .nav:
CSS:
.navholder {
width:950px;
height:350px;
background-color:grey;
text-align:center;
}
.nav {
position:relative;
bottom:0px;
margin:0 auto;
width:800px;
}
This works :
.navholder {
width:950px;
height:350px;
background-color:grey;
text-align: center;
}
.nav {
bottom:0px;
margin: auto;
display: inline-block;
}
Try this
.nav {
text-align: center;
}
the reason margin: 0 auto; does not work is because you have the div's as "inline-block". You can only center inline blocks by centering from their parent.
if you don't want that, you can always try changing this
.button1, .button2, .button3, .button4, .button5, .button6 {
display:inline-block;
}
to this
.button1, .button2, .button3, .button4, .button5, .button6 {
display: block;
}
Or you can just add text-align: center; to .nav
and then just remove float: left; from .button1, .button2, .button3, .button4, .button5, .button6 {
like this:
.nav {
position:relative;
bottom:0px;
text-align: center;
}
.button1, .button2, .button3, .button4, .button5, .button6 {
width:120px;
height:35px;
background-color:rgb(204,204,204);
margin-left:5px;
margin-right:5px;
display:inline-block;
}
Here's the Jsfiddle - http://jsfiddle.net/S6BVL/8/

CSS for div not being rendered for some reason? I think sticky footer is the issue.

I tried implementing CSS sticky footer after I had already built my site and it's not working properly, probably because of some pre-existing code that I haven't been able to pinpoint yet. It seems that the CSS for #content is not being rendered at all, no matter what I try to declare for it. The site is at iphonebuy-host1.gaiahost.net. JSfiddle for iphonebuy-host1.gaiahost.net/thanks.html: http://jsfiddle.net/TqCYh/1/
(The stackoverflow code insert widget isn't working properly right now, sorry for the ridiculous code pasted below!)
* {
border:0;
margin:0;
padding:0;
}
html, body {
height:100%;
}
/** body **/
body {
font-size:100%;
font-family:arial, sans-serif;
line-height:1.3em;
color:#666;
width:100%;
background-image:url(images/greystripe.png);
background-repeat:repeat;
}
/** link styles **/
a,
a:link,
a:active,
a:hover,
a:visited {
text-decoration:none;
outline:none;
}
a:link, a:visited {
color:#0071BC;
}
a:hover, a:active {
color:#99CCCC;
}
/** text heading styles **/
h1 {
font:1.5em arial, sans-serif;
color:#A09F9F;
margin:1.2em 0 0 .7em;
}
h2 {
font:1.5em arial, sans-serif;
color:#95DF00;
margin-bottom:.5em;
}
h3 {
font:1.5em "arial black", sans-serif;
color:#95DF00;
padding-bottom:.5em;
}
h4 {
font:bold 1.313em arial, sans-serif;
color:#666;
}
h5 {
font:1em "arial black", sans-serif;
color:#95DF00;
margin:0;
padding:0;
}
/** for paragraph text **/
p {
font:1em arial, sans-serif;
line-height:1.3em;
text-align:justify;
color:#A09F9F;
margin-bottom:.5em;
padding:0;
}
/** main (container for everything) **/
#main {
background:#FFF;
width:62em;
min-height:100%;
text-align:left;
margin:0 auto;
padding:0.5em 1em 3em 1em;
-moz-box-shadow:0 0 8px 2px #ccc;
-webkit-box-shadow:0 0 8px 2px #ccc;
box-shadow:0 0 8px 2px #ccc;
behavior:url(/pie/PIE.htc);
}
.clearfix {
display: inline-block;
}
.clearfix:after {
content: "\00A0";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
/** header **/
#header {
height:5.5em;
margin:0 0 0 1em;
}
#logo {
margin-left:-.7em;
border:0;
}
/** top & bottom navigation menus **/
.topnav {
list-style:none;
font:1.313em arial, sans-serif;
color:#0071BC;
margin:-1.8em 0 1.2em 25em;
text-align:center;
}
.topnav li {
position:relative;
display:inline;
padding:0 .5em;
border:none;
}
.topnav a, .bottom-nav a {
display:inline-block;
}
.bottom-nav {
float:left;
list-style:none;
font:1em arial, sans-serif;
padding-top:1em;
}
.bottom-nav li {
display:inline;
padding:0 .5em;
margin-top:-2em;
}
/** container for content between header and footer **/
#content {
min-height:100%;
overflow:auto;
padding-bottom:30px;
}
/** footer **/
#footer {
margin-top:-30px;
padding:0 1em;
width:62em;
height:30px;
color:#999;
position:relative;
clear:both;
}
/** Opera Fix for sticky footer **/
body:before {
content:"";
height:100%;
float:left;
width:0;
margin-top:-32767px;/
}
.paypal {
display:block;
margin:-2em 3em 0 19em;
padding-top:2em;
}
.copyright {
margin:-3em 0 0 38.7em;
font-size:.9em;
color:#999;
}
/** for horizontal line under header and above footer **/
hr.styled {
border:0;
height:0;
width:60em;
border-bottom:1px solid #E6E6E6;
}
hr.footer {
border:0;
height:0;
width:60em;
border-bottom:1px solid #E6E6E6;
margin-bottom:1em;
}
/** for vertical lines between menu items and 3 steps **/
.vertical-line {
border-right:1px solid #E6E6E6;
padding:0 1.5em 0 0;
}
/** thank you page **/
#thanks {
}
#thanks h1, #thanks p {
margin:1.5em;
text-align:center;
}
I usually use the technique from Ryan Fait as described here http://ryanfait.com/sticky-footer/
To apply this to your code you would have to do the following:
- move the footer out of your main div, and place it directly in the body. You can only have two wrappers in the body, your main content container and the footer.
- add an extra empty div at the bottom of your main div, and give it an ID like footer-push
- add the following to your css:
#main {
min-height: 100%;
height: auto !important;
height: 100%;
padding: 0;
margin: 0 auto -100px;
}
#footer, #footer-push {
height: 100px;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
That should do the trick. See for yourself: http://jsfiddle.net/TqCYh/3/
I know this technique requires you to add an empty div, which could be considered 'dirty' because you are adding markup that is exclusivly there for styling purpose, but the technique is simple and works great cross browser (IE7+). Having to add special code for IE or Opera or whatever is also dirty imo.
Anyways, this technique works great for me, I use it all the time. Hope it suits your need.
before we start bashing other people's codes:
instead of adding a empty div outside, try this -
html:
<div class="wrap">
<div class="inner-wrap">
...
</div>
</div>
<footer>
...
</footer>
css:
html, body {height:100%;}
.wrap {min-height:100%; height:auto !important; margin-bottom:-100px;}
.inner-wrap {padding-bottom:100px;}
footer {height:100px;}
should do the trick without the empty div.

DIV inline-block + width 100%

I can't display a few DIV's in one line. display: inline-block and float: left doesn't work. My site width is not fixed so I want it to be dynamic to fit any width of screen.
HTML:
<div id="all">
<div id="a">25px</div>
<div id="b">200px</div>
<div id="c">
<div id="c1">100%</div>
<div id="c2">100%</div>
<div id="c3">100%</div>
</div>
500px
</div>
CSS:
DIV {
margin:5px;
font-size:10px;
}
DIV#all {
width:500px;
border:1px dotted black;
}
DIV#a {
display:inline-block;
width:25px;
height:200px;
border:1px solid red;
color:red;
}
DIV#b {
display:inline-block;
width:150px;
height:200px;
border:1px solid green;
color:green;
}
DIV#c {
display:inline-block;
width:auto;
height:200px;
border:1px solid blue;
color:blue;
}
DIV#c1 {
width:auto;
border:1px dotted blue;
color:blue;
}
DIV#c2 {
width:auto;
border:1px dotted blue;
}
DIV#c3 {
width:auto;
border:1px dotted blue;
color:blue;
}​
Live Demos:
PROBLEM: http://jsfiddle.net/BC2d9/
RESOLVED: http://jsfiddle.net/RAds3/ (display:table)
​
The problem with your current attempt is the width: 100%; on the third column div#c. 100% here will be 100% of its parent - which contains all three columns. Depending on what level of flexibility you want you have a few options.
If the site width is fixed, set a fixed width for the third column.
If you want the third column to stretch to its content, set max-width.
If you want the third column to stretch to fill its parent, you're probably better off with (css) tables.
Check out http://somacss.com/cols.html for a great resource on css column layout.
Problem is with third column. You can't set width to 100%. Also, you need float: left;. Here is fixed code:
<div id="all">
<div id="a">25px</div>
<div id="b">200px</div>
<div id="c">
<div id="c1">100%</div>
<div id="c2">100%</div>
<div id="c3">100%</div>
</div>
<div style="clear:both;"></div>
500px
</div>
and CSS:
DIV {
margin:5px;
font-size:10px;
}
DIV#all {
width:500px;
border:1px dotted black;
}
DIV#a {
float: left;
width:25px;
height:200px;
border:1px solid red;
color:red;
}
DIV#b {
float: left;
width:200px;
height:200px;
border:1px solid green;
color:green;
}
DIV#c {
float: left;
width:210px;
min-height:190px;
border:1px solid blue;
color:blue;
padding: 5px;
}
DIV#c1 {
width:100%;
border:1px dotted blue;
color:blue;
margin: 0 0 5px 0;
}
DIV#c2 {
width:100%;
border:1px dotted blue;
margin: 0 0 5px 0;
}
DIV#c3 {
width:100%;
border:1px dotted blue;
color:blue;
margin: 0 0 5px 0;
}​
And also LIVE DEMO
If your site width is fixed, then just replace 100% with all remained width in the container.Example: jsFiddle
If you want it to be dynamic and to fit any width of screen, I think it's not possible with pure CSS. I made it with jQuery:
var containerWidth = $('#all').outerWidth();
var widthLeft = $('#a').outerWidth(true) + $('#b').outerWidth(true);
var widthRight = containerWidth - widthLeft - 20; // 20px = spacing between elements
$('#c').css('width', widthRight+ 'px');
$('#c1, #c2, #c3').css('width', widthRight-10+ 'px'); // 10 = padding on the right side
Modified CSS:
DIV#c {
display:inline-block;
height:200px;
border:1px solid blue;
color:blue;
float: right;
}
DIV#c1 {
border:1px dotted blue;
color:blue;
}
DIV#c2 {
border:1px dotted blue;
}
DIV#c3 {
border:1px dotted blue;
color:blue;
}
Removed width: 100% and set float:right to #c.
Live demo: jsFiddle
Check out this update. I hope is good enough :)
DIV {
margin:5px;
font-size:10px;
}
DIV#all {
width:500px;
border:1px dotted black;
}
DIV#a {
display:inline-block;
width:25px;
height:200px;
border:1px solid red;
color:red;
float:left;
}
DIV#b {
display:inline-block;
width:150px;
height:200px;
border:1px solid green;
color:green;
float:left;
}
DIV#c {
display:inline-block;
width:277px;
height:200px;
border:1px solid blue;
padding:0 7px 0 5px;
color:blue;
float:left;
}
DIV#c1 {
width:100%;
margin:5px 0;
border:1px dotted blue;
color:blue;
}
DIV#c2 {
width:100%;
margin:5px 0;
border:1px dotted blue;
}
DIV#c3 {
width:100%;
margin:5px 0;
border:1px dotted blue;
color:blue;
}
div { float:left; width:10px; height:10px; }
Helps?

Positioning ModalPopupExtender above another ModalPopupExtender

The first ModalPopupExtender appears in the center of the screen, when i show the second ModalPopupExtender it appears bellow and to the right of the first one (though above the first one).
I want to place it in the center of the screen.
Update:
I found that the problem with second popup was:
PopupDragHandleControlID="pnlDragMe"
if i remove this, it's ok.
but i need the drag-control!
This is my drag panel:
<div id="pnlDragMe" class="pnlDragMe">
Image Uploader
</div>
and it's css:
.pnlDragMe
{
background-color: #4D676A;
height: 24px;
cursor: move;
width: 100%;
text-indent: 10px;
}
Page Layout CSS:
/* General styles */
body {
margin:0;
padding:0;
border:0;
width:100%;
background:#fff;
min-width:600px;
font-size:90%;
}
a {
color:#369;
}
/* column container */
.colmask {
position:relative;
clear:both;
float:left;
width:100%;
overflow:hidden;
}
/* 2 column left menu settings */
.leftmenu {
background:#FFD8B7;
}
.leftmenu .colright {
float:left;
width:200%;
position:relative;
left:195px;
background:#fff;
}
.leftmenu .col1wrap {
float:right;
width:50%;
position:relative;
right:200px;
padding-bottom:1em;
}
.leftmenu .col1 {
margin: 0 5px 0 205px;
position:relative;
right:100%;
overflow:hidden;
}
.leftmenu .col2 {
float:left;
position:relative;
/*width:170px;
right:185px;*/
width:170px;
right:190px;
}
/* Footer styles */
#footer {
clear:both;
float:left;
width:100%;
border-top:1px solid #000;
}
#footer p {
padding:10px;
margin:0;
}
Jquery center plugin
This works for me very well

Resources