How do I create one layout in HTML + CSS?
The problem that I have is that I did not realize how to properly split screen.
Can you give a brief example please jsfiddle
Thanks in advance!
EDIT:
I put this example that please if you know to edit any variant of solving the problem. Very important ... the two bottom divs should always be square
https://jsfiddle.net/L3ttfL72/
For square divs, give them the same height and width. For square divs the size of a percentage of the window width, use vh.
div {
box-sizing: border-box;
}
.container {
width: 60vw
}
.banner {
height: 17em; /* whatever you want */
border-color:red; border-style:solid;
border-width: 6px 6px 2px;
}
.bottom {
float: left;
width: 30vw;
height: 30vw;
}
.left {
border-color:green; border-style:solid;
border-width:4px 3px 6px 6px;
}
.right {
border-color:blue; border-style:solid;
border-width:4px 6px 6px 3px;
}
.container::after {
clear: left
}
<div class="container">
<div class="banner">
The top div
</div>
<div class="bottom left">
bottom left
</div>
<div class="bottom right">
bottom right
</div>
</div>
Here is the code you requested. On a side note, I recommend brushing up on your html / css, this is a place to get assistance and posting questions similar is not recommended.
#numOne{
width:60%;
background:red;
height:60vh;
}
#squareOne{
background:green;
width:50%;
height:40vh;
float:left;
}
#squareTwo{
background:blue;
width:50%;
height:40vh;
float:left;
}
#wrapperDiv{
width:60%;
}
body{
margin:0;
padding:0;
}
http://codepen.io/dnwebdev/pen/waRQme
#numOne{
width:60%;
background:red;
height:60vh;
background-size:cover; background:url(http://lorempixel.com/output/cats-h-g-987-1010-10.jpg);
background-repeat: no-repeat;
background-position: center;
}
#squareOne{
background:green;
width:50%;
height:40vh;
float:left;
background-size:cover; background:url(http://lorempixel.com/output/cats-q-g-640-480-3.jpg);
background-repeat: no-repeat;
background-position: center;
}
#squareTwo{
background:blue;
width:50%;
height:40vh;
float:left;
background-size:cover; background:url(http://lorempixel.com/output/cats-q-g-640-480-3.jpg);
background-repeat: no-repeat;
background-position: center;
}
#wrapperDiv{
width:60%;
}
body{
margin:0;
padding:0;
}
<div id="container">
<div id="numOne">
</div>
<div id="wrapperDiv">
<div id="squareOne">
</div>
<div id="squareTwo">
</div>
</div>
</div>
Related
Please help me put these boxes next to each other and not on top of each other. This should be so simple, but for some reason I am not able to figure it out.
https://jsfiddle.net/DShepherd79/6qsg8g1L/2/
<body>
<div class="horAlign">
<a class="rTableCell processMap"></a>
<a class="rTableCell sharepoint"></a>
</div>
</body>
.horAlign{
background-color:black;
width: 500px;
position: absolute;
}
.rTableCell{
padding:25px;
}
/*images Start Here*/
.processMap {
background:#08F80D no-repeat center;
display:block;
height:50px;
width:50px;
}
.sharepoint{
background-color:purple; no-repeat center;
display:block;
height:50px;
width:50px;
}
/*Hover Images Start Here*/
.processMap:hover {
background-color:red; no-repeat center;
}
.sharepoint:hover {
background-color:blue; no-repeat center;
}
Change display:block to display:inline-block
See https://jsfiddle.net/6qsg8g1L/3/
I have 3 seperate portion in page. Each should scroll individually. And if we scroll entire page every div should scroll.
How to achieve that. Following is fiddle for that http://jsfiddle.net/qLonzsvj/
html{
overflow-x:hidden;
}
.left-column
{
float:left;
width:30%;
}
.right-column
{
float:right;
width:30%;
}
.center-column
{
margin:auto;
width:30%;
}
I think this is what you are looking for.
CSS
html, body {
height: 100%;
position:relative;
}
body
{
background:#00253f;
line-height:100px;
text-align:center;
}
.left
{
position:absolute;
margin-left:5%;
margin-top:3%;
display:block;
height:80%;
width:20%;
background:#ddd;
overflow:scroll;
}
.center
{
position:absolute;
margin-left:25%;
margin-top:3%;
display:block;
height:80%;
width:50%;
background:#ccc;
overflow:scroll;
}
.right
{
position:absolute;
margin-left:75%;
margin-top:3%;
display:block;
height:80%;
width:20%;
background:#ddd;
overflow:scroll;
}
HTML
<div class="left"> Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br></div>
<div class="center"> Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br></div>
<div class="right"> Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br>Hello<br></div>
Check demo here
jsfiddle
A few things need to be changed to allow this to work I made a little mock up on jsfiddle you need to give the boxs a defined height and an overflow property of scroll. Also you do not need to float your boxes all willy nilly to make this happen.
:::EDIT:::
Updated Js Fiddle for page scrolling
http://jsfiddle.net/kriscoulson/qLonzsvj/2/
*{
box-sizing: border-box;
}
.cols {
float:left;
width:33%;
overflow: scroll;
height:30px;
}
.left-column{
background: red;
}
.center-column{
background: blue;
}
.right-column{
background: green;
}
<div id="container">
<div class="cols left-column">
<div>div1</div>
<div>div1</div>
<div>div1</div>
</div>
<div class="cols center-column">
<div>div2</div>
<div>div2</div>
<div>div2</div>
</div>
<div class="cols right-column">
<div>div3</div>
<div>div3</div>
<div>div3</div>
</div>
I need to align multiple DIVs horizontally and vertically inside my main DIV divBig. Each DIV should overlap one over the other but should be in the centre of the main DIV divBig.
This is my DIV structure:
<div id="divBig">
<div class="divBigInner">
<img class="innerSub1" src="image.png" />
<div class="innerSub2"></div>
<div class="innerSub3"></div>
</div>
</div>
This is what I tried so far. But Does not align correctly.
#divBig {
background-color: #ff6600;
text-align: center;
}
.divBigInner{
position:relative;
height: 100%;
}
.innerSub1{
position:absolute;
max-width:550px;
width:100%;
z-index: 1;
margin: auto;
pointer-events: none;
}
.innerSub2{
position:absolute;
z-index: 2;
top:10px;
display:inline;
}
.innerSub3{
position:relative;
max-width:550px;
width:100%;
z-index:0;
margin: auto;
pointer-events: none;
}
Thank you.
like this you are asking?
<div id="divBig">
<div class="divBigInner" align="center">
<div class="innerSub1"></div>
<div class="innerSub2"></div>
<div class="innerSub3"></div>
</div>
</div>
Css
<style>
#divBig {
background-color: #fff;
text-align: center;
}
.divBigInner{
height: 100%;
}
.innerSub1,.innerSub2,.innerSub3{
border:1px solid #f00;
padding:10px;
margin:10px;
width:100px;
}
</style>
Can you try this:
<div id="divBig">
<div class="divBigInner" align="center">
<div class="innerSub1"></div>
<div class="innerSub2"></div>
<div class="innerSub3"></div>
</div>
</div>
Css
<style>
#divBig {
background-color: #fff;
text-align: center;
}
.divBigInner{
height: 100%;
position:relative;
}
.innerSub1,.innerSub2,.innerSub3{
border:1px solid #f00;
padding:10px;
margin:10px;
width:100px;
height:100px;
position:absolute;
margin-left:-50px; /*formula to make div center horizontal (left 50% - width/2)*/
margin-top:-50px; /*formula to make div center vertical (top 50% - height/2)*/
}
</style>
Sorry for my english.
I have a problem. I need to create a DIV inside another DIV, which has to have a white background. I tried using skew, but It didnt work well.
Here is an image:
There are at least several ways to achieve this, however the simplest way may be using linear-gradient background. Its quality is not really good compared with others but it's totally acceptable.
Try this:
div {
width:600px;
height:300px;
background:teal;
border:1px solid teal;
}
.top {
width:100%;
height:100px;
font-size:25px;
padding-left:30px;
background:linear-gradient(175deg, white 60%, transparent 62%);
border:none;
box-sizing:border-box;
}
HTML:
<div>
<div class='top'>Custom<br/>Home</div>
</div>
Demo.
You can do that with a pseudo element and transform rotate :
DEMO
HTML :
<div id="header">
Custom<br/>
Home
</div>
<div id="content"></div>
CSS :
#header{
background:#fff;
position:relative;
height:50px;
z-index:1;
font-size:30px;
padding-left:10%;
}
#header:before{
content:'';
position:absolute;
bottom:0;
right:0;
width:110%;
height:1000%;
background:inherit;
z-index:-1;
border-bottom:2px solid #636A6E;
-webkit-backface-visibility: hidden; /* to fix pixelisation in chrome */
-ms-transform-origin:100% 100%;
-webkit-transform-origin:100% 100%;
transform-origin:100% 100%;
-webkit-transform: rotate(-5deg);
-ms-transform: rotate(-5deg);
transform: rotate(-5deg);
}
#content{
min-height:500px;
background:#778385;
}
Since you need the border in your diagonal div, try this:
CSS:
.logo {
width:110%;
height:147px;
top:-10%;
left:-14px;
border:2px solid black;
position:absolute;
background:#fff;
transform:rotate(-7deg);
-ms-transform:rotate(-7deg);
/* IE 9 */
-webkit-transform:rotate(-7deg);
/* Opera, Chrome, and Safari */
}
.container {
width:100%;
height:612px;
overflow:hidden;
background:#7b8284;
position:relative;
}
.inner {
position:absolute;
height:200px;
transform:rotate(7deg);
-ms-transform:rotate(7deg);
/* IE 9 */
-webkit-transform:rotate(7deg);
/* Opera, Chrome, and Safari */
padding:20px 90px;
top:30%;
font-size:30px;
}
HTML:
<div class="container">
<div class="logo">
<div class="inner">My Logo</div>
</div>
</div>
Demo: http://jsfiddle.net/lotusgodkk/BKfe9/1/
You can modify the top,left,font-size,background-color,transform, border as per your need
If you want to do it in pure CSS I would recommend using the transform: rotate(xxx) feature of CSS3. I've created a JS-Fiddle that will help you get started (not the best solution...), it is not based on your fiddle: http://jsfiddle.net/syTu7/
I think I understand your question, I think my example will help
HTML
<div class="wrapper">
<div class="innter">some text</div>
</div>
CSS
.wrapper {
position: relative;
width: 960px;
margin: 0 auto;
background: #ddd;
min-height: 100%;
height: 800px;
}
.innter {
height: 500px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: #ececec;
}
In HTML,
<div class="wrapper">
<div class="inner">some content</div>
</div>
In CSS,
.inner {
background: #fff;
}
So I have this template design that is currently absolutely positioned, but I'm trying to make it centered in any widescreen browser. I've tried making the width auto on the left and right side in my container, but it is still aligned with the left side.
Css
.JosephSettin_png
{
position: absolute;
left:0px;
top:0px;
width:216px;
height:40px;
background: url("JosephSettin.png") no-repeat;
}
.home_png
{
position: absolute;
left:472px;
top:16px;
width:48px;
height:16px;
}
.discography_png
{
position: absolute;
left:528px;
top:16px;
width:80px;
height:24px;
}
.purchase_png
{
position: absolute;
left:608px;
top:16px;
width:88px;
height:24px;
}
.about_png
{
position: absolute;
left:696px;
top:16px;
width:48px;
height:24px;
}
.contact_png
{
position: absolute;
left:744px;
top:16px;
width:56px;
height:24px;
}
.main__pic_png
{
position: absolute;
left:0px;
top:56px;
width:264px;
height:264px;
background: url("main_pic.png") no-repeat;
}
.footer__lines_png
{
position: absolute;
left:0px;
top:512px;
width:800px;
height:24px;
background: url("footer_lines.png") no-repeat;
}
.info__heading_png
{
position: absolute;
left:32px;
top:360px;
width:216px;
height:32px;
background: url("info_heading.png") no-repeat;
}
.info__pic3_png
{
position: absolute;
left:265px;
top:360px;
width:159px;
height:112px;
background: url("info_pic3.png") no-repeat;
}
.info__pic2_png
{
position: absolute;
left:432px;
top:360px;
width:176px;
height:112px;
background: url("info_pic2.png") no-repeat;
}
.info__pic1_png
{
position: absolute;
left:616px;
top:360px;
width:177px;
height:112px;
background: url("info_pic1.png") no-repeat;
}
.info__pane_png
{
position: absolute;
left:0px;
top:345px;
width:800px;
height:144px;
background: url("info_pane.png") no-repeat;
}
body
{
text-align: center;
background-color:maroon;
}
#wrapper {
width: 800px;
margin-left: auto;
margin-right: auto;
text-align: left;
}
#a {
text-decoration: none;
color:white;
font-weight:bold;
}
.style1 {
font-weight: bold;
color: #FFFFFF;
}
html
<body>
<center>
<div id="wrapper">
<div class="JosephSettin_png"> </div>
<div class="home_png"> Home</div>
<div class="discography_png"> Discography</div>
<div class="purchase_png"><span class="style1">Store</span></div>
<div class="about_png">About</div>
<div class="contact_png"><span class="style1"></span>Contact</div>
<div class="ad_png"> </div>
<div class="main__pic_png"> </div>
<div class="welcome__header_png"> </div>
<div class="welcome__text_png"> </div>
<div class="footer__lines_png"> </div>
<div class="footer__text_png"> </div>
<div class="info__pane_png"></div>
<div class="info__heading_png"> </div>
<div class="info__text_png"> </div>
<div class="info__pic3_png"> </div>
<div class="info__pic2_png"> </div>
<div class="info__pic1_png"> </div>
<div class="info__pic3_png"> </div>
</div>
</center>
</body>
I know the container I create works if all my div classes aren't absolutely positioned. Do I have to change the position or did I make another error?
Add position: relative; to the .wrapper definition.
http://www.w3.org/TR/CSS2/visuren.html#choose-position
An absolutely positioned item must be inside of a relatively positioned item, or it will not display as you intended.
Your main problem is that your wrapper needs to be position:relative; and margin:0 auto; will center the wrapper. also you can get rid of you HTML element its not needed.
CSS:
#wrapper {
position:relative;
width: 800px;
margin:0 auto;
text-align: left;
}
Hope this helps.
I strongly suggest using a CSS framework like "Blueprint CSS". It'll save you a lot of time and helps not just with positioning of elements but comes with a lot of nice features like typography, css reset for multi-browser support, etc.