Div longer than 100% - html

HTML:
<div id="wrap">
<div id="main">
<p id="title">home</p>
</div>
</div>
CSS:
body,div,dl,dt,dd,ol,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
margin:0;
padding:0;
}
html, body {
height:100%;
margin:0;
padding:0;
}
#wrap {
background-image: -ms-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: -moz-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: -o-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: -webkit-gradient(radial, center center, 0, center center, 506, color-stop(0, #FFFFFF), color-stop(1, #0662BF));
background-image: -webkit-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: radial-gradient(circle farthest-corner at center, #FFFFFF 0%, #0662BF 100%);
height:100%;
padding:0;
margin:0;
}
#main {
height: 100%;
margin-right: 15%;
margin-left: 15%;
border-right: 1px solid gray;
border-left: 1px solid gray;
padding: 0px 15px 15px 15px;
background-color: #FFFFFF;
text-align: center;
}
I feel dumb asking questions like this because I feel like the answer is extremely simple, but my main div is longer than the wrap and I don't understand why. I could just make the main div shorter so it matches the wrap, but I want to do it properly.
JSFiddle

Your #main-div has a padding of 15px on the bottom.
Add this to your css:
padding: 0;
Or better modify your css-code from padding: 0px 15px 15px 15px; to
padding: 0px 15px 0px 15px;
See your updated fiddle here: http://jsfiddle.net/k7tRy/

Because of padding.
Remove bottom padding, or add to #main
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;

Your div #main have some padding-bottom.
In your Css class : padding: 0px 15px 15px 15px;.
It means :
padding-top: 0px;
padding-right: 15px;
padding-bottom: 15px;
padding-left: 15px;
And your div takes more than 100% because of padding property.
(Padding: Padding is extra space inside the control.)
You should/can use margin instead of padding.

<style>
body,div,dl,dt,dd,ol,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
margin:0;
padding:0;
}
html, body {
height:100%;
margin:0;
padding:0;
}
#wrap {
background-image: -ms-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: -moz-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: -o-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: -webkit-gradient(radial, center center, 0, center center, 506, color-stop(0, #FFFFFF), color-stop(1, #0662BF));
background-image: -webkit-radial-gradient(center, circle farthest-corner, #FFFFFF 0%, #0662BF 100%);
background-image: radial-gradient(circle farthest-corner at center, #FFFFFF 0%, #0662BF 100%);
height:100%;
padding:0;
margin:0;
}
#main {
height: 100%;
margin-right: 15%;
margin-left: 15%;
border-right: 1px solid gray;
border-left: 1px solid gray;
<!-- Check the change -->
padding: 0px 15px 0px 15px;
background-color: #FFFFFF;
text-align: center;
}
</style>
<div id="wrap">
<div id="main">
<p id="title">home</p>
</div>
</div>
I agree to the above developers. It just because you are giving an extra padding at the bottom of your main div.
Just for the caution, always check the conventions while coding:
padding: top-padding, right-padding, bottom-padding,left-padding.
(Just to remember: it works in a clockwise fashion)
Hope it helps. Happy Coding :)

Related

Can't center elements in responsive

I built a basic web and I'm trying to make it responsive, but I'm having some issues with the slider itself; some elements don't center when I resize the screen; I thought it was because of Firefox, but I tried on chrome and the result is the same.
The slider is:
<div id="slider" class="slider-big">
<div class="vertical-relative-centered">
<h1>Welcome everyone!!!</h1>
Ir al Blog
</div>
</div>
And the css:
#slider {
width: 100%;
height: 350px;
/* line-height: 320px; */
color: #fff;
text-shadow: 0 0 5px #444;
overflow: hidden;
background: rgba(73,155,234,1);
background: -moz-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, rgba(73,155,234,1)), color-stop(100%, rgba(32,124,229,1)));
background: -webkit-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: -o-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: -ms-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: radial-gradient(ellipse at center, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#499bea', endColorstr='#207ce5', GradientType=1 );
}
#slider h1 {
margin: 0;
padding: 0;
text-align: center;
}
.btn-white {
display: inline-block;
color: rgb(88, 88, 88);
background-color: white;
padding: 10px;
margin: auto;
margin-top: 40px;
font-size: 18px;
text-transform: uppercase;
text-shadow: none;
box-shadow: 0 0 5px rgb(88, 88, 88);
border-radius: 4px;
transition: 300ms all;
}
.btn-white:hover {
background-color: #444;
color: white;
}
The thing is that the h1 moves left when I resized the screen, so my solution was to add an overflow: hidden to #slider, and it works quite well, but I got another issue which is because of the overflow, the slider doesn't stick to the header when I resize; then, I removed the overflow and I tried to center it horizontally with a translateX(), but the h1 ignored it.
So, at the end, I don't know how to center the element in a right way and, at the same time, get the slider sticks to the header.
This is the full code in case you need it: https://jsfiddle.net/ilos28/t9ouea7v/
Thanks in advance.
-------------- Added ---------------
This is the difference, when I change the wide of the screen:
Before:
After:
In the end I just had to set a height 100% in the #menu and the space disappeared.

Overflow logo outside nav bar

I've tried the overflow-y: visible in css but the logo still cuts, i imagine it has something to do with the body since, in all the other pages the logo shows as i want it to.
<div class="nav-logo">
<img class="lightup-logo" src="image/logo.png" alt=""/>
</div>
.nav-logo {
float: left;
overflow-y: visible;
width: 24%;
padding: 0px;
margin: 0px;
}
On a side note the logo works as intended in all other pages, it overflows nicely, its just in the index page that the problem seems to appear.
For those who are looking for a complete code sample.
<header>
<div class="header-container">
<div class="nav-logo">
<img class="lightup-logo" src="image/logo.png" alt=""/>
</div>
</div>
</header>
<main>
<div class="body-container">
<div class="large-container"></div>
<div class="clear"></div>
</div>
</main>
header {
padding: 0px;
margin: 0px;
background: rgba(31,34,36,1);
background: -moz-linear-gradient(left, rgba(31,34,36,1) 0%, rgba(0,0,0,1) 25%, rgba(0,0,0,1) 50%, rgba(0,0,0,1) 77%, rgba(31,34,36,1) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(31,34,36,1)), color-stop(25%, rgba(0,0,0,1)), color-stop(50%, rgba(0,0,0,1)), color-stop(77%, rgba(0,0,0,1)), color-stop(100%, rgba(31,34,36,1)));
background: -webkit-linear-gradient(left, rgba(31,34,36,1) 0%, rgba(0,0,0,1) 25%, rgba(0,0,0,1) 50%, rgba(0,0,0,1) 77%, rgba(31,34,36,1) 100%);
background: -o-linear-gradient(left, rgba(31,34,36,1) 0%, rgba(0,0,0,1) 25%, rgba(0,0,0,1) 50%, rgba(0,0,0,1) 77%, rgba(31,34,36,1) 100%);
background: -ms-linear-gradient(left, rgba(31,34,36,1) 0%, rgba(0,0,0,1) 25%, rgba(0,0,0,1) 50%, rgba(0,0,0,1) 77%, rgba(31,34,36,1) 100%);
background: linear-gradient(to right, rgba(31,34,36,1) 0%, rgba(0,0,0,1) 25%, rgba(0,0,0,1) 50%, rgba(0,0,0,1) 77%, rgba(31,34,36,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1f2224', endColorstr='#1f2224', GradientType=1 );
}
.nav-logo {
float: left;
overflow-y: visible;
width: 230px;
height: 100%;
width: 24%;
padding: 0px;
margin: 0px;
}
.header-container {
max-width: 1000px;
margin: auto;
border-left: 0px;
border-right: 0px;
border-top: 0px;
border-bottom: 1px solid transparent;
-webkit-border-image: url(/border.png) 28 stretch; /* Safari 3.1-5 */
-o-border-image: url(/border.png) 28 stretch; /* Opera 11-12.1 */
border-image: url(/border.png) 28 stretch;
}
main {
margin: 0px;
padding: 0px;
}
.large-container {
height: 478px;
background-image: url(../image/sliced1.png);
}
.body-container {
margin: auto;
max-width: 1000px;
position: relative;
}
If i add z-index: -1 to the body-container i get the result i want (logo overflows) however links in the body-containers no longer work.
screen_styles.css, line 48, remove z-index: 5px;. z-index has nothing to do with pixels.
add these rules to header line 14:
header {
position: relative;
z-index: 99;
}
That's about it. The reason why z-index did not work was because you were trying to use it on a position:static element. It only works on elements with position other than static.
Your project has quite a few errors, you should have a decent front end developer look at it before you launch, to put it mildly.
try
.nav-logo img
{
max-width: 100px; //width of div
max-height: 100px;//height of div
}
or you can make logo.png, background of div
<div class="nav-logo">
</div>
and use
.nav-logo {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url("image/logo.png");
background-repeat: no-repeat;
background-size: contain;
}
contain makes background image fill the div and not getting bigger.

How do I make the green background color be half of the whole div?

I wonder why the div bar doesn't show green background color halfway, from left to middle. It just show the whole div bar. What could be the problem? THanks..
.BioUploadProgressBar p {
display: block;
width: 350px;
padding: 2px 5px;
margin: 12px 0;
border: 1px inset #446;
border-radius: 5px;
}
.BioUploadProgressBar p.initialize {
/*background: #0c0 none 0 0 no-repeat;*/
background-color: #0c0;
background-image: none;
background-position: 50% 0px;
background-repeat: no-repeat;
}
<div>
<div class='BioUploadProgressBar'>
<p class="initialize">Upload file 0 %</p>
</div>
</div>
Background-Position only applies to Background-Image. You'll have these options:
Use a Background-Image (But also have an additional Request)
Use a second DIV
Use a CSS Gradient (http://www.colorzilla.com/gradient-editor/ - No IE8 and stuff)
Try using this:
.progress {
height: 20px;
overflow: hidden;
background-color: #F5F5F5;
border-radius: 4px;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1) inset;
}
.cpu {
color: #FFF;
text-align: center;
transition: width 2.0s ease 0s;
background-color: #FF6633;
}
<div class="progress" style="width:500px;">
<div id="cpu" class="cpu" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 10%">
<span>10</span>
</div>
</div>
because your HTML is incorrect and your CSS is even more incorrect, you're using background properties that applies to background images, not colors, change your HTML to this:
<div>
<div class='BioUploadProgressBar'>
<div class="initialize">Upload file 0 %</div>
</div>
</div>
and your CSS to this:
.BioUploadProgressBar {
display: block;
width: 350px;
margin: 12px 0;
border: 1px solid #446;
border-radius: 5px;
}
.initialize {
border-radius: 5px;
display:inline-block;
background: #0c0;
width:175px;
;
padding:5px;
}
see FIddle
Gradient solution via colorzilla
.partialGradiend{
background: -moz-linear-gradient(left, rgba(0,204,0,1) 0%, rgba(0,204,0,1) 50%, rgba(0,204,0,0) 51%, rgba(0,204,0,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,204,0,1)), color-stop(50%,rgba(0,204,0,1)), color-stop(51%,rgba(0,204,0,0)), color-stop(100%,rgba(0,204,0,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(0,204,0,1) 0%,rgba(0,204,0,1) 50%,rgba(0,204,0,0) 51%,rgba(0,204,0,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(0,204,0,1) 0%,rgba(0,204,0,1) 50%,rgba(0,204,0,0) 51%,rgba(0,204,0,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(0,204,0,1) 0%,rgba(0,204,0,1) 50%,rgba(0,204,0,0) 51%,rgba(0,204,0,0) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(0,204,0,1) 0%,rgba(0,204,0,1) 50%,rgba(0,204,0,0) 51%,rgba(0,204,0,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00cc00', endColorstr='#0000cc00',GradientType=1 ); /* IE6-9 */
width:300px;
border: 1px inset #446;
border-radius: 5px;
text-align:center;
padding:10px 0px;
}
<div class="partialGradiend" style="">
50%
</div>

Does anyone know why does my Contact Us sidebar div link has white space between rounded border and gradient?

I have a contact us gradient div link on my sidebar with a rounded border. The rounded border isn't right on the edge of the gradient div all the way around. The result is there is white space in between the gradient and the border at the bottom and right side. How do I fix this?
I created a fiddle but it is slightly different in the fiddle. There is no white spaces and the div text has an underline. Check it out for yourself.
The fiddle:
http://jsfiddle.net/D0rZa/63mrE/
<div id="sidebar">
<p>Any Questions?</p>
<div class="sidebar-butt">Contact Us</div>
</div>
#sidebar {
float: right;
width: 238px;
color: #000000;
padding-right: 5px;
padding-left: 5px;
height: 250px;
border: 1px solid #28A9D6;
border-radius: 8px;
margin-top: 4px;
margin-right: 5px;
}
.sidebar-butt {
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.27, #496FE3),
color-stop(1, #121B3E));
background-image: -o-linear-gradient(bottom, #496FE3 27%, #121B3E 100%);
background-image: -moz-linear-gradient(bottom, #496FE3 27%, #121B3E 100%);
background-image: -webkit-linear-gradient(bottom, #496FE3 27%, #121B3E 100%);
background-image: -ms-linear-gradient(bottom, #496FE3 27%, #121B3E 100%);
background-image: linear-gradient(to bottom, #496FE3 27%, #121B3E 100%);
width:110px;
height:28px;
color:#fbfbfb !important;
border-radius:25px;
-webkit-border-radius:25px;
-moz-border-radius:25px;
border: 1px solid #002799;
font: Bold 16px Verdana;
padding: 5px 10px;
text-align: center;
}
.sidebar-butt:hover {
background:linear-gradient(to bottom, #4970E3 0%, #121B3E 100%) repeat scroll 0% 0% transparent;
background: -moz-linear-gradient(to bottom, #4970E3 0%, #121B3E 100%) repeat scroll 0% 0% transparent;
background: -webkit-linear-gradient(to bottom, #4970E3 0%, #121B3E 100%) repeat scroll 0% 0% transparent;
width:110px;
height:28px;
color:#fbfbfb;
border-radius:25px;
-webkit-border-radius:25px;
-moz-border-radius:25px;
border: 1px solid #002799;
font: Bold 16px Verdana;
background: #060652;
}
.sidebar-butt a {
color: #fbfbfb;
}
My website:
http://osweb01.ostech.com.au/
#sidebar li {
list-style-type: none;
padding:0px;
/* float:left; remove this */
background-image: url(images/narrow.gif);
background-repeat: no-repeat;
background-position: 8px 15px;
/* border: 1px solid #AACCEE; remove this */
background-color: #FFF;
width: 230px;
margin-bottom: 20px;
}

Navigation UL/LI additional space

It's one of those days and I can not figure out why I'm getting a space to the left of each of the LI tags in the following code. If you hover over, the menu items you'll see what I mean.
http://jsfiddle.net/midnitesonnet/C2Dub/
<div id="wrapper">
<div id="menu">
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
</div>
<div id="content">Content</div>
<div id="footer">Footer</div>
</div>
I can not figure out why I'm getting a space to the left of each of the LI tags
Because you format them with display:inline-block - and have whitespace between the tags. That's basic "HTML behavior", that any whitespace between two inline(-block) elements is condensed to one space character when displayed.
Either float the LI instead, or write them without whitespace between the tags, meaning ...</li><li>...
try this
http://jsfiddle.net/C2Dub/4/
/* CSS Document */
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.9em;
margin-top: 0px;
background-color: #f5f5f5;
}
#wrapper {
background-color: #ffffff;
width: 1000px;
margin: auto;
-webkit-box-shadow: 0px 0px 6px rgba(50, 50, 50, 0.64);
-moz-box-shadow: 0px 0px 6px rgba(50, 50, 50, 0.64);
box-shadow: 0px 0px 6px rgba(50, 50, 50, 0.64);
/*-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;*/
}
#menu {
background: #505050;
background: -moz-linear-gradient(top, #505050 0%, #343434 50%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#505050), color-stop(50%,#343434));
background: -webkit-linear-gradient(top, #505050 0%,#343434 50%);
background: -o-linear-gradient(top, #505050 0%,#343434 50%);
background: -ms-linear-gradient(top, #505050 0%,#343434 50%);
background: linear-gradient(to bottom, #505050 0%,#343434 50%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#505050', endColorstr='#343434',GradientType=0 );
min-height: 26px;
color: #CCC;
}
#menu ul {
display: block;
height: 39px;
list-style: none outside none;
margin: 0;
padding: 0;
}
#menu li {
margin: 0;
display: inline-block;
height: 39px;
border-right: 1px solid rgb(0, 0, 0);
padding: 0px 20px !important;
line-height: 39px;
list-style: none;
float:left;
}
#menu li a {
display: inline-block;
width: 99%;
color: #CCC;
text-decoration: none;
}
#menu li:hover {
background: #6b6b6b;
background: -moz-linear-gradient(top, #6b6b6b 0%, #4c4c4c 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6b6b6b), color-stop(100%,#4c4c4c));
background: -webkit-linear-gradient(top, #6b6b6b 0%,#4c4c4c 100%);
background: -o-linear-gradient(top, #6b6b6b 0%,#4c4c4c 100%);
background: -ms-linear-gradient(top, #6b6b6b 0%,#4c4c4c 100%);
background: linear-gradient(to bottom, #6b6b6b 0%,#4c4c4c 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6b6b6b', endColorstr='#4c4c4c',GradientType=0 );
}
#content {
min-height: 600px;
padding: 5px;
}
#footer {
min-height: 50px;
background: #f4f7f5;
background: -moz-linear-gradient(top, #f4f7f5 0%, #edf5f7 37%, #d3e8e6 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f7f5), color-stop(37%,#edf5f7), color-stop(100%,#d3e8e6));
background: -webkit-linear-gradient(top, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
background: -o-linear-gradient(top, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
background: -ms-linear-gradient(top, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
background: linear-gradient(to bottom, #f4f7f5 0%,#edf5f7 37%,#d3e8e6 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f7f5', endColorstr='#d3e8e6',GradientType=0 );
border-top: 1px #D2D2D2 solid;
}
This seems to work, I floated your li's, removed some padding and changed the height of the menu: http://jsfiddle.net/C2Dub/5/
#menu {
background: #505050;
background: -moz-linear-gradient(top, #505050 0%, #343434 50%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#505050), color-stop(50%,#343434));
background: -webkit-linear-gradient(top, #505050 0%,#343434 50%);
background: -o-linear-gradient(top, #505050 0%,#343434 50%);
background: -ms-linear-gradient(top, #505050 0%,#343434 50%);
background: linear-gradient(to bottom, #505050 0%,#343434 50%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#505050', endColorstr='#343434',GradientType=0 );
min-height: 39px;
color: #CCC;
}
#menu ul {
display: block;
padding: 0;
margin: 0;
list-style: none;
}
#menu li {
margin: 0;
float: left;
height: 19px;
border-right: 1px solid rgb(0, 0, 0);
padding: 10px 20px !important;
list-style: none;
}
U have some whitespace characters between your HTML code try to put the li tags on eachtoher:
<ul>
<li>Home</li>
<li>Home</li>
<li>Home</li>
</ul>
This solved the problem in the Fiddle.