I'm currently trying to fully understand how all the positioning code works and to make everything responsive in my website. I've come across a rather irritating issue.
THE ISSUE
-I have a div that is positioned relative (id: news_content) and is within a div that is positioned absolute (id: page). When I try to move news_content using positioning commands top and left, left is the only one that is reacting. While the top command isn't moving news_content at all.
/*Global*/
body {
margin:0;
padding:0;
}
div {
margin:0;
padding:0;
top:0;
left:0;
bottom:0;
right:0;
}
table {
margin:0;
padding:0;
border-spacing:0;
}
/*Global Divs*/
#page {
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
}
#nav_main {
background-color:black;
width:100%;
height:14%;
position:fixed;
z-index:0;
}
/*Navigation*/
#nav_content {
background-color:gray;
width:12.5%;
height:86%;
position:fixed;
top:14%;
z-index:-1;
}
#nav_side_container {
background-color:black;
width:60%;
height:93%;
position:relative;
top:3.5%;
left:18.75%;
}
#nav_side {
background-color:red;
width:75%;
height:93%;
position:relative;
top:3.5%;
left:12.75%;
}
#nav_side table {
width:100%;
height:100%;
font-family:'Playball';
font-size:1.25em;
font-weight:bold;
text-align:center;
}
#nav_side table td {
width:100%;
height:33.33%;
border-top:0.1em solid black;
}
/*News*/
#news_content {
background-color:red;
width:87.5%;
height:86%;
position:relative;
top:14%;
left:12.5%;
z-index:-2;
}
/*
#news {
background-color:black;
width:10em;
height:10em;
position:relative;
left:10em;
}
#news_main {
background-color:blue;
width:10em;
height:10em;
position:relative;
}
#news_side {
background-color:green;
width:10em;
height:10em;
position:relative;
}
/*Articles*/
#articles_content {
background-color:blue;
width:87.5%;
height:86%;
position:relative;
left:12.5%;
z-index:-2;
}
/*Future Plans*/
#future_content {
background-color:green;
width:87.5%;
height:86%;
position:relative;
left:12.5%;
z-index:-2;
}
<div id="page">
<div id="nav_main">
</div>
<div id="nav_content">
<div id="nav_side_container">
<div id="nav_side">
<table>
<tr>
<td>News</td>
</tr>
<tr>
<td>Articles</td>
</tr>
<tr>
<td>Future<br>Plans</td>
</tr>
</table>
</div>
</div>
</div>
<div id="news_content">
<div id="news">
</div>
<div id="news_main">
</div>
<div id="news_side">
</div>
</div>
<div id="articles_content">
</div>
<div id="future_content">
</div>
</div>
..
-No idea what the problem is to be truthfully... It could be my knowledge on how relative and absolute positioning is wrong or my code being complete haywire.
It's because your #page id doesn't have a height on it. If you give it height: 100%;, that should do it.
Related
All I am trying to do is replace the black box with a box that will blur the background image. This is an over simplified version of my webpage. If I can just get this code corrected, I can figure out the rest.
Here's my example and code:
https://jsfiddle.net/no_u_turn/8ymc7xeb/1/
body {
background-image:url('https://i.ibb.co/DKtSK1h/background-image.jpg');
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
}
.top-box {
width:100%;
height:600px;
text-align:center;
padding-top:100px;
}
.blur-background-box {
width:300px;
height:300px;
background-color:black;
/*filter:blur(5px);*/
margin:0 auto;
padding-top:50px;
}
.solid-white-box {
width:200px;
height:200px;
background-color:white;
margin:0 auto;
}
.bottom-box {
width:100%;
height:1000px;
background-color:white;
}
<div class="top-box">
<div class="blur-background-box">
<div class="solid-white-box">
</div>
</div>
</div>
<div class="bottom-box">
</div>
Oh yeah, I need this done in CSS only, no JavaScript. Basically, I need the code to work with all browsers and across all devices.
I'll be working on this all night. Any and all suggestions are welcome! Thx in advance.
since you are using background-attachment:fixed; you can then apply the same background on the black box and you will have the needed effect. To avoid having the content blurred use a pseudo element:
body {
background-image:url('https://i.ibb.co/DKtSK1h/background-image.jpg');
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
}
.top-box {
width:100%;
height:600px;
text-align:center;
padding-top:100px;
}
.blur-background-box {
width:300px;
height:300px;
margin:0 auto;
padding-top:50px;
position:relative;
z-index:0;
}
.blur-background-box:before {
content:"";
position:absolute;
z-index:0;
top:0;
left:0;
bottom:0;
right:0;
background-image:url('https://i.ibb.co/DKtSK1h/background-image.jpg');
background-attachment:fixed;
background-repeat:no-repeat;
background-size:cover;
filter:blur(5px);
}
.solid-white-box {
width:200px;
height:200px;
background-color:white;
margin:0 auto;
position:relative;
z-index:1;
}
.bottom-box {
width:100%;
height:1000px;
background-color:white;
}
<div class="top-box">
<div class="blur-background-box">
<div class="solid-white-box">
</div>
</div>
</div>
<div class="bottom-box">
</div>
I am trying to make two columns separated by or inside a circle page the second column should have an image it like this :
<div class="step second">
<div id="upload-img"></div>
<div id="sperator">
<div class="circle" id="or"><p class="number" style="padding-left:25%;">or</div>
</div>
<div id="default-img">
<img src=""/>
</div>
</div>
But for some reason the position of the #sperator div is changing with the image my css is bit long so here is a js fiddle for more explaining : here
As you can see the image should be in the same line with the other div but its changing the position of the separator div
You should re-check your html tags. Make sure each tag closed correctly
Here your css :
.step{
position:relative;
width:500px;
height:250px;
border:1px solid black;
}
#upload-img{
position:absolute;
left:0;
top:0;
width:50%;
height:100%
}
#default-img{
position:absolute;
right:0;
top:0;
width:50%;
height:100%
}
#upload-img img, #default-img img{
max-width:100%;
max-height:100%;
}
#sperator .circle{
position:absolute;
height:66px;
width:66px;
background-color:black;
top:50%;
left:50%;
margin:-33px auto auto -33px;
border-radius:50%;
z-index:100;
text-align:center;
}
#sperator .circle p{
font-size:35px;
font-family:futura-book;
color:white;
padding:0 !important;
margin:0;
line-height:60px;
}
.step::after{
content:'';
height:100%;
width:3px;
left:50%;
margin-left:-2px;
z-index:90;
position:absolute;
background-color:black;
}
potition:relative will be an area that will "lock" every potition:absolute inside it.
You can use position:relative as parent div and position:absolute as child div.
I'm new to CSS and this is just some training stuff. I created a basic layout and I add a navigation bar with some a elements. The problem is that you can't see the full a elements. I tried to change the margin-top property to 0 but nothing changed. How could I solve this problem?
#container{
width:100%;
height:100%;
position:absolute;
}
#Header{
position:absolute;
top:0;
left:0;
width:100%;
height:20%;
background-color:#FFF1D5;
}
#nav
{
position:absolute;
top:20%;
left:0;
width:100%;
height:5%;
background-color:#660033;
text-align:center;
}
#nav ul li{
text-decoration:none;
display:inline-block;
margin-left:25px;
margin-right:25px;
margin-top:0;
}
#nav ul li a{
font-size:25px;
color:white;
position:center;
text-decoration:none;
display:inline-block;
}
#leftnav
{
position:absolute;
left:0;
top:25%;
width:20%;
height:55%;
background-color:yellow;
}
#body
{
position:absolute;
top:25%;
left:20%;
width:60%;
height:55%;
background-color:silver;
}
#rightnav
{
position:absolute;
top:25%;
right:0;
width:20%;
height:55%;
background-color:yellow;
}
#Footer{
position:absolute;
bottom:0;
left:0;
height:20%;
width:100%;
background-color:green;
}
edit :
`<!DOCTYPE html>
<html>
<head>
<link href = "üben_css.css" rel = "stylesheet">
<title> K </title>
</head>
<body>
<div id="container">
<div id="Header"> Das ist der Header </div>
<div id="nav">
<ul>
<li>Home</li>
<li>Produkte </li>
<li>Kontakt </li>
</ul>
</div>
<div id="body"> Das ist der body </div>
<div id="leftnav"> Linke Navigation</div>
<div id="rightnav"> Rechte Navigation</div>
<div id ="Footer"> Footer</div>
</div>
</body>
</html>`
If I am understanding your question then:
#Header{
position:absolute;
top:0;
left:0;
width:100%;
height:20%; /* This is set to 20%, try increase it */
background-color:#FFF1D5;
}
Since your elements have the position attribute you can assign them the z-index attribute to control which one goes on top. Also, I personally wouldn't have that many elements with the position: absolute on there. It'll be a mess of work if you decide you want to move one of them. Try assigning some of them with position: relative.
http://www.w3schools.com/cssref/pr_pos_z-index.asp
UPDATE
After doing some testing and localhost modifications I have found out what I need:
The website must not be scrollable, only the content area.
When zooming the sidebar height should stay consistently to the bottom of the page.
The header must also zoom in and out but remain full width
Fiddle:
http://jsfiddle.net/dkx2q/2/
Something like this maybe:
CSS
body{
background-color:rgb(0,0,0);
}
#container{
display:block;
width:100%;
height:100%;
}
#fullScreenImage{
float:left;
width:25%;
height:100%;
background-color:rgb(124,197,118);
position:relative;
}
#content{
float:left;
width:75%;
height:100%;
}
#header{
display:block;
height:15%;
background-color:rgb(94,142,178);
position:relative;
}
#sidebar{
float:left;
height:85%;
width:20%;
background-color:rgb(162,94,179);
position:relative;
}
#contentArea{
float:left;
width:80%;
height:85%;
background-color:rgb(255,255,255);
position:relative;
}
span{
position:absolute;
top:50%;
width:100%;
text-transform:uppercase;
font-weight:bold;
font-family:Helvetica, 'Helvetica Neue', 'Arial Block', Arial;
font-size:9em;
text-align:center;
}
#header span{
font-size:7em;
top:40%;
}
HTML
<body>
<div id='container'>
<div id='fullScreenImage'><span>Full Screen Image</span>
</div>
<div id='content'>
<div id='header'><span>Header</span></div>
<div id='sidebar'>
<span>Sidebar</span>
</div>
<div id='contentArea'><span>Content Area</span></div>
</div>
</div>
</body>
My code is viewable at http://jsfiddle.net/ATbA5/2/ code will also be at the end of this post
I am trying to make content-wrapper 100% height however for it to be centered. I have looked at other theards on stackoverflow and Can't find a solution. Also A fixed footer at the end of the page not the bottom of the broswer window
HTML
<head>
<link rel="stylesheet" type="text/css" href="primary-resources/css/main-styles.css"/>
</head>
<body>
<div class="content-wrapper">
<!-- Header -->
<div class="header">
<div class="threetwentyleft">
<img src="primary-resources/imgs/header-logo.png" />
</div>
<div class="sixfortyright">
<div class="gameAdBanner">
<img src="game-resources/gameone/imgs/banner.png"/>
</div>
</div>
</div>
<!-- Content -->
<div class="gameLeft"></div>
<div class="gameRight"></div>
</div>
</body>
</html>
CSS
body ,html {
background-color:#000000;
height:100%;
top:0px;
bottom:0px;
clear:both;
padding:0px;
margin:0px;
}
.content-wrapper {
margin:auto;
background-color:#ffffff;
width:960px;
padding:0px;
bottom:0;px;
top:0px;
margin:auto;
box-sizing:border-box;
height:100%;
box-sizing:border-box;
clear:both;
box-sizing:border-box;
}
.header {
width:100%;
}
.threetwentyleft {
width:320px;
float:left;
padding:2px;
}
.threetwentyleft img{
width:320px;
padding:2px;
border:0px;
}
.sixfortyright {
width:630px;
float:right;
height:130px;
}
.gameAdBanner {
width:610px;
margin-top:2px;
margin-left:auto;
margin-right:auto;
}
.center {
margin-left:auto;
margin-right:auto;
}
.gameLeft {
width:700px;
padding:5px;
float:left;
}
.gameRight {
width:260px;
background-color:#CCC;
float:right;
padding:5px;
height:100%;
margin-right:3px;
}
.footer {
width:960px;
background-color:#FC6;
bottom:0px;
height:25px;
position:absolute;
}
Sounds like you want normal html behaviour, no need for any css, just add a div, or any block element after the content.