page wrapper isn't containing or wrapping at all? - html

Not sure, my isn't wrapping all the way down. Now to make things easier I added borders to everything and background colors to everything. So here is my html...
Now I could add a float left to the page-wrapper div, but that is a hack and not the right way to do it. Now everything is working just the way it is even the way its setup now, but I don't like what a div isn't wrapping, its really annoying.
Here is the JSFiddle http://jsfiddle.net/ywgpB/15/
HTML
<div id="page-wrapper">
<div class="leftContainer">
<article class="welcome">
<header>
<h2>Welcome!</h2>
<img src="../images/dummy_125x125.png">
<p>Dummy Text</p>
</header>
</article>
<article class="hours">
<header>
<h2>Working Hours</h2>
<p>MON - FRI 5:00 AM to 11:00 PM
<br />SAT - SUN 7:00 AM to 8:00 PM</p>
</header>
</article>
<article class="location">
<header>
<h2>Location</h2>
</header>
</article>
</div>
<section id="main">
<div id="banner"></div>
<div class="containBox">
<article class="box">
<h2>Our Members</h2>
<p></p>
<button></button>
</article>
<article class="box">
<h2>Classes</h2>
<p></p>
<button></button>
</article>
<article class="box">
<h2>Programs</h2>
<p></p>
<button></button>
</article>
</div>
</section>
</div>
CSS
body{
background-image: url(../images/pageglare.png);
background-repeat: no-repeat;
color: #000305;
font-size: 87.5%;
font-family: Tahoma, Arial, "Lucida Sans Unicode";
line-height: 1.5;
text-align: left;
}
#page-wrapper{
margin: 0 auto;
width: 90%;
background-color: pink;
clear: both;
border: 2px solid darkorange;
}
.logoContainer{
width: 15%;
border: 2px solid blue;
margin: 2% 0;
}
.leftContainer{
border: 2px solid darkcyan;
width: 25%;
float: left;
background-color: cyan;
display: block;
}
.welcome{
width: 100%;
}
.welcome img{
float: left;
}
.hours{
float: left;
width: 100%;
}
.location{
float: left;
width: 100%;
}
#main{
width: 65%;
margin: 0 2%;
border: 2px solid green;
float: left;
background-color: lightgreen;
}
#banner{
width: 98%;
height: 300px;
border: 2px solid gray;
float: left;
}
.containBox{
margin-left: 1%;
width: 97%;
border: 2px solid black;
height: 250px;
clear: both;
background-color: gray;
float: left;
}
.box{
width: 30%;
border: 2px solid red;
height: 250px;
float: left;
}

Add overflow: hidden to wrapper, or element with clear: both after floating elements.
#page-wrapper {overflow: hidden}
http://jsfiddle.net/ywgpB/16/

Related

How to make a grid with images inside a div with HTML?

I am trying to make a grid of pictures with padding in between inside the main_block div. I cant get the images to aline next to eachother and then break it with a becouse they go inline. inline block does not work. I tried making a new div for these images but i cant resize the pictures nor give them padding. I tried to make the pictures resizable but without results. iut is as if something is overriding the size of the pictures. The pictures stack upon eachother and im trying to maaake a grid.
Thanks in advance for any help!
This would be the optimal solution.
Here is the fiddle
https://jsfiddle.net/q2cr9ttL/1/
<style>
body {
margin: 0;
padding: 0;
}
#header {
background-color: #ff6600;
color: white;
text-align: left;
padding: 2px;
}
#nav {
line-height: 30px;
background-color: #fff000;
height: 350px;
width: 125px;
float: left;
padding: 5px;
}
#section {
width: 350px;
float: left;
padding: 10px;
}
#footer {
background-color: #737373;
color: white;
clear: both;
text-align: center;
}
#container {
margin: auto;
width: 900px;
text-align: left;
overflow: hidden;
}
.inner_block {
display: inline-block;
text-align: center;
width: 350px;
height: 200px;
}
.main_block {
text-align: center;
width: 750px;
}
.grid_block {
display: inline-block;
text-align: center;
width: 29%px;
height:100px;
}
</style>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<body>
<div id="container">
<!---container--->
<div id="header">
<h1>JORDAS</h1>
</div>
<!--header-->
<div id="nav">
Etusivu
<br>
Teltat
<br>
Palvelut
<br>
Yhteistiedot
<br>
</div>
<div id="section">
<div class="main_block">
<div class="grid_block">
<img src=Grafik/basictalt.png>
</div>
<div class="grid_block">
<img src=Grafik/basictalt.png >
</div>
<div class="grid_block">
<img src=Grafik/basictalt.png>
</div>
</div><!--mainblock-->
</div>
<div id="footer">
<h3>POP-UP TELTTOJEN YKKÖNEN </h3>
</div>
<!--footer-->
</div>
<!--container-->
</body>
You could use the flex display property.
You will need to include some prefixes for cross browser compatibility.
* {
box-sizing: border-box;
}
.main_block {
display: flex;
flex-wrap: wrap;
}
.grid_block {
width: 33%;
padding: 1.4em
}
.grid_block img {
max-width: 100%
}
/* ORIGINAL STYLES */
body {
margin: 0;
padding: 0;
}
#header {
background-color: #ff6600;
color: white;
text-align: left;
padding: 2px;
}
#nav {
line-height: 30px;
background-color: #fff000;
height: 350px;
width: 125px;
float: left;
padding: 5px;
}
#section {
width: 350px;
float: left;
padding: 10px;
}
#footer {
background-color: #737373;
color: white;
clear: both;
text-align: center;
}
#container {
margin: auto;
width: 900px;
text-align: left;
overflow: hidden;
}
.inner_block {
display: inline-block;
text-align: center;
width: 350px;
height: 200px;
}
.main_block {
text-align: center;
width: 750px;
}
.grid_block {
display: inline-block;
text-align: center;
width: 29%px;
height: 100px;
}
<div id="container">
<!---container--->
<div id="header">
<h1>JORDAS</h1>
</div>
<!--header-->
<div id="nav">
Etusivu
<br>
Teltat
<br>
Palvelut
<br>
Yhteistiedot
<br>
</div>
<div id="section">
<div class="main_block">
<div class="grid_block">
<img src=http://lorempixel.com/image_output/city-q-c-640-480-9.jpg>
</div>
<div class="grid_block">
<img src=http://lorempixel.com/image_output/city-q-c-640-480-9.jpg >
</div>
<div class="grid_block">
<img src=http://lorempixel.com/image_output/city-q-c-640-480-9.jpg>
</div>
</div><!--mainblock-->
</div>
<div id="footer">
<h3>POP-UP TELTTOJEN YKKÖNEN </h3>
</div>
<!--footer-->
</div>
<!--container-->

separator by not using width hack

I often do the width hack 49% and border 1px to do seperator for 2 column. It worked, just like the below demo. But is there any better way of doing it? I want to avoid this 49% hack, because when the viewport shrink to a larger or smaller size, it's obvious and the design will break.
body{
margin:0;
}
.left {
background: #eee;
float: left;
width: 49%;
border-right:1px solid #333;
}
.right {
background: #eee;
float: right;
width: 50%;
}
img {
margin: 0 auto;
display: block;
width: 44px;
padding: 5px 0;
}
<div class="navigate" style="width: 170px;">
<div class="left">
<img src="https://cdn0.iconfinder.com/data/icons/arrow-set/512/previous_arrow_point_flat-128.png">
</div>
<div class="right">
<img src="https://cdn0.iconfinder.com/data/icons/arrow-set/512/next_arrow_point_flat-128.png">
</div>
</div>
You can use box-sizing
CSS
body {
margin:0;
}
.left {
background: #eee;
float: left;
width: 50%;
border-right:1px solid #333;
box-sizing:border-box;
}
.right {
background: #eee;
float: right;
width: 50%;
}
img {
margin: 0 auto;
display: block;
width: 44px;
padding: 5px 0;
}
HTML
<div class="navigate" style="width: 170px;">
<div class="left">
<img src="https://cdn0.iconfinder.com/data/icons/arrow-set/512/previous_arrow_point_flat-128.png">
</div>
<div class="right">
<img src="https://cdn0.iconfinder.com/data/icons/arrow-set/512/next_arrow_point_flat-128.png">
</div>
</div>
DEMO HERE

Auto height of outer div [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i know this has been asked before an such, but i've tried like 5 different ways from Stack and 5 from other websites, and i can't seemsto find the right one.
It's a simple problem, the php_content div aren't getting bigger as it should be with content put into it.
/******************************************************
/ CSS RESET
/*****************************************************/
html,body,div,ul,ol,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,fieldset,input,hr {margin:0; padding:0;}
h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,em,strong,th {font-size:1em; font-weight:normal; font-style:normal;}
ul,ol {list-style:none;}
fieldset,img,hr {border:none;}
caption,th {text-align:left;}
table {border-collapse:collapse; border-spacing:0;}
td {vertical-align:top;}
/*****************************************************/
*{
box-sizing: border-box;
float: left;
}
.container{
width: 1000px;
height: 600px;
}
.code{
float: left;
width: 800px;
height: 600px;
background-color: #333333;
font-weight: bold;
}
.php{
position: relative;
top: 100px;
left: 100px;
}
.php_start,
.if_start{
display: inline-block;
clear: left;
height: 15px;
min-width: 100px;
background-color: #CD8B32;
border-radius: 5px 5px 5px 0;
}
.php_start span,
.if_start span{
margin-left: 20px;
color: white;
font-size: 12px;
}
.php_content,
.if_content{
display: inline-block;
clear: left;
min-width: 100px;
min-height: 50px;
border-left: 10px solid #CD8B32;
}
.php_end,
.if_end{
display: inline-block;
clear: left;
height: 15px;
min-width: 100px;
background-color: #CD8B32;
border-radius: 0 5px 5px 5px;
}
.code .if{
position: absolute;
}
.toolbox{
float: left;
width: 200px;
height: 600px;
background-color: #333333;
border-left: 2px solid lightgrey;
}
<div class="container">
<div class="code">
<div class="php">
<div class="php_start">
<span>PHP</span>
</div>
<div class="php_content">
<div class="if">
<div class="if_start">
<span>IF</span>
</div>
<div class="if_content">
<div style="height: 100px;"></div>
</div>
<div class="if_end"></div>
</div>
</div>
<div class="php_end"></div>
</div>
</div>
<div class="toolbox">
<div class="if">
<div class="if_start">
<span>IF</span>
</div>
<div class="if_content">
</div>
<div class="if_end"></div>
</div>
</div>
</div>
Your php_content div contains a div that is absolutely positioned, which means php_content cannot match the size of its contents.
The fix is to remove this:
.code .if{
position: absolute;
}
Live Example:
/******************************************************
/ CSS RESET
/*****************************************************/
html,body,div,ul,ol,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,fieldset,input,hr {margin:0; padding:0;}
h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,em,strong,th {font-size:1em; font-weight:normal; font-style:normal;}
ul,ol {list-style:none;}
fieldset,img,hr {border:none;}
caption,th {text-align:left;}
table {border-collapse:collapse; border-spacing:0;}
td {vertical-align:top;}
/*****************************************************/
*{
box-sizing: border-box;
float: left;
}
.container{
width: 1000px;
height: 600px;
}
.code{
float: left;
width: 800px;
height: 600px;
background-color: #333333;
font-weight: bold;
}
.php{
position: relative;
top: 100px;
left: 100px;
}
.php_start,
.if_start{
display: inline-block;
clear: left;
height: 15px;
min-width: 100px;
background-color: #CD8B32;
border-radius: 5px 5px 5px 0;
}
.php_start span,
.if_start span{
margin-left: 20px;
color: white;
font-size: 12px;
}
.php_content,
.if_content{
display: inline-block;
clear: left;
min-width: 100px;
min-height: 50px;
border-left: 10px solid #CD8B32;
}
.php_end,
.if_end{
display: inline-block;
clear: left;
height: 15px;
min-width: 100px;
background-color: #CD8B32;
border-radius: 0 5px 5px 5px;
}
.toolbox{
float: left;
width: 200px;
height: 600px;
background-color: #333333;
border-left: 2px solid lightgrey;
}
<div class="container">
<div class="code">
<div class="php">
<div class="php_start">
<span>PHP</span>
</div>
<div class="php_content">
<div class="if">
<div class="if_start">
<span>IF</span>
</div>
<div class="if_content">
<div style="height: 100px;"></div>
</div>
<div class="if_end"></div>
</div>
</div>
<div class="php_end"></div>
</div>
</div>
<div class="toolbox">
<div class="if">
<div class="if_start">
<span>IF</span>
</div>
<div class="if_content">
</div>
<div class="if_end"></div>
</div>
</div>
</div>
/******************************************************
/ CSS RESET
/*****************************************************/
html,body,div,ul,ol,li,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,fieldset,input,hr {margin:0; padding:0;}
h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,em,strong,th {font-size:1em; font-weight:normal; font-style:normal;}
ul,ol {list-style:none;}
fieldset,img,hr {border:none;}
caption,th {text-align:left;}
table {border-collapse:collapse; border-spacing:0;}
td {vertical-align:top;}
/*****************************************************/
*{
box-sizing: border-box;
float: left;
}
.container{
width: 1000px;
height: 600px;
}
.code{
float: left;
width: 800px;
height: 600px;
background-color: #333333;
font-weight: bold;
}
.php{
position: relative;
top: 100px;
left: 100px;
}
.php_start,
.if_start{
display: inline-block;
clear: left;
height: 15px;
min-width: 100px;
background-color: #CD8B32;
border-radius: 5px 5px 5px 0;
}
.php_start span,
.if_start span{
margin-left: 20px;
color: white;
font-size: 12px;
}
.php_content,
.if_content{
display: inline-block;
clear: left;
height: auto !important;
min-width: 100px;
min-height: 50px;
border-left: 10px solid #CD8B32;
}
.php_end,
.if_end{
display: inline-block;
clear: left;
height: 15px;
min-width: 100px;
background-color: #CD8B32;
border-radius: 0 5px 5px 5px;
}
.code .if{
position: relative;
}
.toolbox{
float: left;
width: 200px;
height: 600px;
background-color: #333333;
border-left: 2px solid lightgrey;
}
<div class="container">
<div class="code">
<div class="php">
<div class="php_start">
<span>PHP</span>
</div>
<div class="php_content">
<div class="if">
<div class="if_start">
<span>IF</span>
</div>
<div class="if_content">
<div style="height: 100px;"></div>
</div>
<div class="if_end"></div>
</div>
</div>
<div class="php_end"></div>
</div>
</div>
<div class="toolbox">
<div class="if">
<div class="if_start">
<span>IF</span>
</div>
<div class="if_content">
</div>
<div class="if_end"></div>
</div>
</div>
</div>
Change position: absolute to relative in the .code .if block. This way the reference will be set to the div containing it.

How to align text to the right side of an img without using float:left so it wont change the default parent div height

How to I align text to the right side of the image icon like the one in the example picture.
I would usually use "float:left" but it's for a mobile responsive design so I prefer not using things like "float:left" because it ruins the red divs height with responsive designs.
I have to align the title, subsitle and a little square image.
It is easy to use float: left and NOT break the height of red border div.
You only have to add display: table-cell to the .app_top block. Here's the solution:
.app_top {
display: table-cell;
}
.app_top img {
float: left;
}
See the working example. Here's the code.
You could use display: inline-block instead.
#main-container {
border: 5px solid #3F3F3F;
width: 270px;
}
.container {
width: 250px;
height: 200px;
border: 5px solid #7F0008;
margin: 5px;
}
.box {
display: inline-block;
vertical-align: top;
width: 85px;
height: 85px;
background: #446C74;
margin: 5px;
}
.content {
display: inline-block;
vertical-align: top;
}
.title, .sub-title {
margin: 0;
padding: 3px 10px 3px 0;
}
.title {
font-size: 17px;
font-weight: bold;
}
.sub-title {
font-weight: bold;
color: #3F3F3F;
}
.img {
background: url(http://placehold.it/100/25);
width: 100px;
height: 25px;
border: 5px solid #EBEAAE;
}
<div id="main-container">
<div class="container">
<div class="box">
</div>
<div class="content">
<p class="title">Title</p>
<p class="sub-title">Sub-Title</p>
<div class="img"></div>
</div>
</div>
<div class="container">
<div class="box">
</div>
<div class="content">
<p class="title">Title</p>
<p class="sub-title">Sub-Title</p>
<div class="img"></div>
</div>
</div>
</div>
Maybe another option is to put the attribute in a parent div instead of the element
html:
<div id="wrapper">
<div class="twoColumn">
<img src="https://pbs.twimg.com/profile_images/444650714287972352/OXTvMFPl.png" />
</div>
<div class="twoColumn">
<p> this is a testingalot test</p>
<button> mybutton </button>
</div>
</div
css:
#wrapper{
border: 1px solid black;
}
.twoColumn{
width: 49%;
float:left;
border: 1px solid red;
}
button{
width: 50px;
height: 40px;
background: red;
}
img{
max-width: 100%;
}
http://jsfiddle.net/Equero/df2wvcet/
I hope it's help
Most simple solution would be to change your markup structure by wrapping your spans in a div just the way you did with the image, then add .app_top div{display:inline-block} .app_top div span{display:block}
.top{
width: 95%;
position: fixed;
background-color: #f7f7f7;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 3%;
padding-right: 3%;
border-bottom: 1px solid #b2b2b2;
}
.search{
width: 100%;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: none;
background-color: #e3e3e6;
}
.search::-moz-focus-inner {
border: 0;
padding: 0;
}
.items{
background-color: #ffffff;
width: 100%;
padding-top: 50px;
}
.app{
margin-left: 25px;
margin-right: 25px;
}
.app_top div{display:inline-block}
.app_top div span{display:block}
<div class="main">
<div class="top" >
<input type="text" class="search" />
</div>
<!-- Items -->
<div class="items" style="border: 1px solid black; padding-top: ">
<div class="app" style="border: 1px solid red;" >
<div class="app_top">
<div>
<img src="_img1.jpg" width="95"/>
</div>
<div>
<span class="app_txt" style="border: 1px solid aqua;"> text text - House text house! Las...</span>
<span class="ltd" style="border: 1px solid pink;"> textic-texttive ltd</span>
<span class="" style="border: 1px solid blue;"> </span>
</div>
</div>
<div class="app_bottom">
</div>
</div>
</div>
.content contains all text in right side. If you use overflow:hidden the height of div will stay normal.
img { float:left; }
.content { overflow:hidden; }

Building a 3 column div?

I'm trying to build a 3 column div and center all of them inside a wrapper but the div.left and div.right wont stay at the top when the div.middle has text in & when i replace display: inline-block to float: left they stop centering, what could i do so they all center and stay at the top?
example
the html:
<div class="left">
</div>
<div class="middle">
example <p>
example <p>
example <p>
example <p>
example <p>
example <p>
example <p>
</div>
<div class="right">
</div>
</div>
</body>
the css:
.wrapper {
margin-left: auto;
margin-right: auto;
width: 100%;
text-align: center;
}
img {
width: 200px;
height: 200px;}
div.left, div.right {
margin: 3px;
border: 1px solid #0000ff;
display: inline-block;
width: 18%;
padding: 1px;
background: red;
}
div.middle {
margin: 3px;
border: 1px solid #0000ff;
display: inline-block;
width: 60%;
padding: 1px;
background: red;
}
Try using vertical-align
Working Example
div.left, div.right {
margin: 3px;
border: 1px solid #0000ff;
display: inline-block;
width: 18%;
padding: 1px;
background: red;
vertical-align: top; /* see here */
}
MDN documentation for vertical-align
Just do vertical-align: top; on the left/right like this:
http://jsfiddle.net/RJR2V/2/
But if you want them to be even in heights than I suggest display: table-cell;
Like this:
http://jsfiddle.net/RJR2V/1/
under .wrapper all div should be vertical-aligned to top
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
.wrapper {
margin-left: auto;
margin-right: auto;
width: 100%;
text-align: center;
}
img {
width: 200px;
height: 200px;
}
div.left, div.right {
margin: 3px;
border: 1px solid #0000ff;
display: inline-block;
width: 18%;
padding: 1px;
background: red;
}
div.middle {
margin: 3px;
border: 1px solid #0000ff;
display: inline-block;
width: 60%;
padding: 1px;
background: red;
}
.wrapper div{
vertical-align:top;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="left">
</div>
<div class="middle">
example <p>
example
<p>
example
<p>
example
<p>
example
<p>
example
<p>
example
<p>
</div>
<div class="right">
</div>
</div>
</body>
</html>