Body border surrounding all my page (NOT FIXED) - html

What I want is creating a border surrounding all my page content, the top border is fine but the others and especially the bottom border is not positioned where I want, I want it to be always in the bottom of my page.
html,
body {
min-height: 100%;
height: 100%;
}
body {
margin: 0;
padding: 45px;
min-height: 100%;
z-index: 1;
}
#barTop,
#barLeft,
#barBottom,
#barRight {
display: block;
position: absolute;
background-color: #f8ee53;
z-index: 2;
}
#barTop,
#barBottom {
right: 20px;
left: 20px;
height: 25px;
}
#barTop {
top: 20px;
}
#barBottom {
bottom: 20px;
}
#barLeft,
#barRight {
top: 20px;
bottom: 20px;
width: 25px;
}
#barLeft {
left: 20px;
}
#barRight {
right: 20px;
}
<div id="barTop"></div>
<div id="barRight"></div>
<div id="barBottom"></div>
<div id="barLeft"></div>
Result:
My border does not include all the content of my page.

remove this :
html,
body {
min-height: 100%;
height: 100%;
}
and use this
body {
margin: 0;
padding: 45px;
min-height: 100%;
z-index: 1;
}
#barTop, #barLeft, #barBottom, #barRight {
display: block;
position: absolute;
background-color: #f8ee53;
z-index: 2;
}
#barTop, #barBottom {
right: 20px;
left: 20px;
height: 25px;
}
#barTop {
top: 20px;
}
#barBottom {
bottom: 20px;
}
#barLeft, #barRight {
top: 20px;
bottom:20px;
width: 25px;
}
#barLeft {
left: 20px;
}
#barRight {
right: 20px;
}

You should be able to fix this by adding the following under your existing body selector:
body {
box-sizing: border-box;
}
I made a jsfiddle that demonstrates it, with a black background on the body to better illustrate it:
JS Fiddle

The problem is caused by the padding on the body. It is not taken into account when the height is calculated at 100%. Either remove the padding or do what mtr web suggested and add box-sizing: border-box; Run the snippet below to see it work.
html,
body {
min-height: 100%;
height: 100%;
}
body {
margin: 0;
padding: 45px;
min-height: 100%;
z-index: 1;
box-sizing: border-box;
}
#barTop,
#barLeft,
#barBottom,
#barRight {
display: block;
position: absolute;
background-color: #f8ee53;
z-index: 2;
}
#barTop,
#barBottom {
right: 20px;
left: 20px;
height: 25px;
}
#barTop {
top: 20px;
}
#barBottom {
bottom: 20px;
}
#barLeft,
#barRight {
top: 20px;
bottom: 20px;
width: 25px;
}
#barLeft {
left: 20px;
}
#barRight {
right: 20px;
}
<div id="barTop"></div>
<div id="barRight"></div>
<div id="barBottom"></div>
<div id="barLeft"></div>

Related

align text in between two div with postioning

I am trying to create a progression section, where i have a text, image and progression.
I am able to achieve this but the problem here is that i want the image section and text should be vertical middle align to the parent div.
Is there a way i can use flex instead of relative and absolute.
.progress-bar-container {
background-color: #33cc33;
width: 100%;
position: fixed;
bottom: 0;
z-index: 1;
height: 40px;
}
img {
width: 20px;
height: 20px;
}
.progress-info-wrapper {
position: absolute;
}
.text-wrapper {
color: #263238;
margin-left: 8px;
}
.progress {
height: 40px;
width: 11%;
background-color: #99ff99;
}
<div class="progress-bar-container">
<div class="progress-info-wrapper">
<img src="https://i.picsum.photos/id/237/200/300.jpg?hmac=TmmQSbShHz9CdQm0NkEjx1Dyh_Y984R9LpNrpvH2D_U"
alt="test-img"><span class="text-wrapper">Add more items to get offer</span></div>
<div class="progress"></div>
</div>
You mean something like that? Add some flex properties to your .progress-info-wrapper class.
.progress-info-wrapper {
position: absolute;
display:flex;
align-items: center;
height: 100%;
}
.progress-bar-container {
background-color: #33cc33;
width: 100%;
position: fixed;
bottom: 0;
z-index: 1;
height: 40px;
}
.progress-info-wrapper {
position: absolute;
display:flex;
align-items: center;
height: 100%;
}
img {
width: 20px;
height: 20px;
}
.text-wrapper {
color: #263238;
margin-left: 8px;
}
.progress {
height: 40px;
width: 11%;
background-color: #99ff99;
}
<div class="progress-bar-container">
<div class="progress-info-wrapper">
<img src="https://i.picsum.photos/id/237/200/300.jpg?hmac=TmmQSbShHz9CdQm0NkEjx1Dyh_Y984R9LpNrpvH2D_U"
alt="test-img"><span class="text-wrapper">Add more items to get offer</span></div>
<div class="progress"></div>
</div>
To vertically align your image and text, you should use flexbox in progress-info-wrapper
.progress-bar-container {
background-color: #33cc33;
width: 100%;
position: fixed;
bottom: 0;
z-index: 1;
height: 40px;
}
img {
width: 20px;
height: 20px;
}
.progress-info-wrapper {
position: absolute;
display: flex;
align-items: center;
height: 100%;
}
.text-wrapper {
color: #263238;
margin-left: 8px;
}
.progress {
height: 40px;
width: 11%;
background-color: #99ff99;
}
<div class="progress-bar-container">
<div class="progress-info-wrapper">
<img src="https://i.picsum.photos/id/237/200/300.jpg?hmac=TmmQSbShHz9CdQm0NkEjx1Dyh_Y984R9LpNrpvH2D_U"
alt="test-img"><span class="text-wrapper">Add more items to get offer</span></div>
<div class="progress"></div>
</div>
Flex would help you with layout deciding how the items will need to be positioned next to each other but not over each other.
In that case position:absolute still fits better. To center the element you need the magic of margin: auto but you should give your element an height using fit-content.
Here's your demo with the .progress-info-wrapper css rules changed as:
.progress-info-wrapper {
position: absolute;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: fit-content;
}
.progress-bar-container {
background-color: #33cc33;
width: 100%;
position: fixed;
bottom: 0;
z-index: 1;
height: 40px;
}
img {
width: 20px;
height: 20px;
}
.progress-info-wrapper {
position: absolute;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: fit-content;
}
.text-wrapper {
color: #263238;
margin-left: 8px;
}
.progress {
height: 40px;
width: 11%;
background-color: #99ff99;
}
<div class="progress-bar-container">
<div class="progress-info-wrapper">
<img
src="https://i.picsum.photos/id/237/200/300.jpg?hmac=TmmQSbShHz9CdQm0NkEjx1Dyh_Y984R9LpNrpvH2D_U"
alt="test-img">
<span class="text-wrapper">Add more items to get offer</span>
</div>
<div class="progress"></div>
</div>

Two floating divs over an image

Alright so I got 1 div that is float left and one with float right, now for some reason I cannot make them go to the side where they should be. They are kinda now both overlapping eachother
* {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
}
html, body {
width: 100%;
height: 100%;
}
#main {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
}
#main img {
width: 100%;
height: 100%;
}
#page_left, #page_right {
width: 50%;
height: 100%;
background-color: red;
position: absolute;
left: 0px;
top: 0px;
z-index: 1000;
}
<div id="main">
<img src="img/background.jpg"/>
<div id="page_left"></div>
<div id="page_right"></div>
</div>
I also tried using a method with display inline block but it didnt work out so well
Try this with your additional css
CSS
#page_left, #page_right {
width: 50%;
height: 100%;
background-color: red;
position: absolute;
top: 0px;
z-index: 1000;
}
#page_left {
left: 0;
}
#page_right {
right: 0;
}
#page_left, #page_right {
width: 50%;
height: 100%;
background-color: red;
position: absolute;
top: 0px;
z-index: 1000;
}
remove left: 0px
OR
remove position: absolute
#page_left, #page_right {
width: 50%;
height: 100%;
background-color: red;
z-index: 1000;
}
the overflow in happened because you given left:0px and position:absolute for both the divs,I'm solved this and and added the snippet below.
* {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
}
html, body {
width: 100%;
height: 100%;
}
#main {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
}
#main img {
width: 100%;
height: 100%;
}
#page_left, #page_right {
width: 50%;
height: 100%;
background-color: red;
position: absolute;
top: 0px;
z-index: 1000;
}
#page_left{
left: 0px;
}
#page_right{
background-color:green;
float:right;
position: absolute;
right: 0px;
}
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="main">
<img src="img/background.jpg"/>
<div id="page_left">
</div>
<div id="page_right">
</div>
</div>
</body>
</html>

Mobile browser cuts off bottom of content but works in desktop browser

Bottom keeps getting cut of in mobile view but perfectly fine in browser even when it's resized. I thought maybe the media queries aren't being addressed but they look fine. I've tried moving .square up by putting top:-55%; but it will only move in desktop browser. It doesn't move in mobile for some reason.
<meta name="viewport" content="initial-scale=1">
/* Iphone */
#media (min-width: 300px) and (max-width: 767px) {
.project_miniwrap {
min-width: 90%;
top: 33%;
}
#tu {
margin-top: 117px;
margin-left: 235px
}
#dar {
margin-top: 17px;
margin-left: 25px
}
.square {
color: #0D0D0D;
font-family: 'NimbusSansNo5TOT-Medium';
font-size: 38px;
letter-spacing: -1px;
display: block;
margin: auto;
position: absolute;
top: -15%;
left: 0;
bottom: 0;
right: 0;
width: 295px;
height: 160px
}
.l1,
.l2,
.l3,
.l4 {
position: absolute;
background: transparent;
width: 0px;
height: 0px;
background-color: black;
color: #0D0D0D
}
.l1 {
left: 0;
bottom: 0;
width: 8px
}
.l2 {
top: 0;
left: 0;
height: 8px
}
.l3 {
right: 0;
top: 0;
width: 8px
}
.l4 {
bottom: 0;
right: 0;
height: 8px
}
.description {
width: 90%
}
.snippet {
display: block;
width: 100%;
line-height: 45px;
margin-bottom: 10%;
font-size: 36px
}
.main_description {
display: block;
width: 100%
}
#anchor-point {
bottom: 90%;
position: absolute
}
.anchor-point {
bottom: 90%;
position: absolute
}
#container {
top: 30%
}
}
#media (max-height: 479px) {
#tu {
margin-top: 117px;
margin-left: 235px
}
#dar {
margin-top: 17px;
margin-left: 25px
}
.square {
color: #0D0D0D;
font-family: 'NimbusSansNo5TOT-Medium';
font-size: 38px;
letter-spacing: -1px;
display: block;
margin: auto;
position: absolute;
top: -15%;
left: 0;
bottom: 0;
right: 0;
width: 295px;
height: 160px
}
.l1,
.l2,
.l3,
.l4 {
position: absolute;
background: transparent;
width: 0px;
height: 0px;
background-color: black;
color: #0D0D0D
}
.l1 {
left: 0;
bottom: 0;
width: 8px
}
.l2 {
top: 0;
left: 0;
height: 8px
}
.l3 {
right: 0;
top: 0;
width: 8px
}
.l4 {
bottom: 0;
right: 0;
height: 8px
}
}
Site: http://imdarrien.com/
I think it's being cut off because the viewport height is not large enough. Since you position .project_miniwrap using top:35%;, it's always going to position it at 35% from the top of the parent, not in the center.
Try using this to center the the div instead:
.project_miniwrap {
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
This is the more compatible version of the above that you can use if you know the width and height, otherwise you will need to center it using JavaScript.
.project_miniwrap {
top: 50%;
left: 50%;
width: 200px;
height: 300px;
margin-left: -100px;
margin-right: -150px;
}

Why is the video overlapping the container?

If you extend the result window, the video overlaps the section below it.
I want the video to stay within the height of the section, in this case height:100vh.
How would I go about this? Here's a jsFiddle.
* {
padding: 0px;
margin: 0px;
}
.Page-01 {
width: 100%;
height: 100vh;
background-color: #0000ff;
margin: 0;
padding: 0;
z-index: 15;
}
.Page-02 {
width: 100%;
height: 100vh;
background-color: #FFFF00;
margin: 0;
padding: 0;
border: 0;
z-index: 15;
}
#videowrapper {
padding-bottom: 56.2%;
overflow: hidden;
z-index: 15;
height: 0;
}
#videowrapper iframe {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.Page-03 {
width: 100%;
height: 100vh;
background-color: #FF0000;
margin: 0;
padding: 0;
z-index: 15;
}
There is some odd stuff going on there because #videowrapper iframe is set to height: 100%; but its parent's height is #videowrapper { height: 0; padding-bottom: 56.2%;
Try setting this instead:
#videowrapper {
overflow: hidden;
z-index: 15;
height: 100%;
}

css background color not working with <div>

body {
background-color: #FFFDEC;
}
.header {
position: fixed;
top: 0;
left: 0;
height: 50px;
width: 100%;
background-color: #04A7A6;
margin: 0;
display: block;
z-index: 10;
}
.headermenu {
xposition: fixed;
top: 50px;
left: 0;
height: 50px;
width: 100%;
background-color: #333;
color: #333;
margin: 0;
overflow: visible;
z-index: 20;
}
This code => doesn't display my second header...? I know it has something to do with the header conflicting with the headermenu, but it doesn't conflict with the body background?
should
xposition:fixed;
be
position:fixed;
?
Working Fiddle