What i want is to make this divisions using Bootstrap and AngularJS
What i don't know how to do is to make the divisions, i was thinking to split the container in 3 columns of 4. Also want to know if can i split the container in two columns of 6 and overlap another div to make the SECTOR 3?
This is what i said before, but this doesn't give me what i want.
<div class="container" contenteditable="false">
<div class="col-md-6 text-center">
<button class="btn btn-default">Button</button>
</div>
<div class="col-md-6 text-center">
<button class="btn btn-default">Button</button>
</div>
</div>
EDIT 1
Also would like to know how to get this responsiveness when loading the site on a smartphone.
Plunker
HTML:
<div class="container">
<div class="content">
<div class="content-body">
<div class="section1 pull-left">section 1</div>
<div class="section2 pull-right">section 2</div>
<div class="section3">section 3</div>
</div>
</div>
</div>
CSS:
/* Reset */
html, body { height: 100%; margin: 0; padding: 0; }
.container {
display: table;
width: 100%;
height: 100%;
}
.content {
display: table-row;
height: 100%;
}
.content-body {
display: table-cell;
}
.section1 {
width: 50%;
background: red;
height: 100%;
display:block;
}
.section2 {
width: 50%;
height: 50%;
height: 100%;
display: block;
background: blue;
}
.section3 {
position: absolute;
left: 0;
right: 0;
bottom: 0;
margin: 0 auto;
height: 50%;
width: 50%;
background: yellow;
}
For responsive style changes you need to add a media query:
#media (max-width: 768px) {
.section3, .section2, .section1 {
display:block;
position: relative;
}
.section3 {
height: 10%;
width: 100%
}
.section2 {
height:60%;
width: 100%
}
.section1 {
height: 30%;
width: 100%
}
}
Related
I am wondering, if there are any alternative/better ways to create this dashboard layout with flex or maybe grid? So I wouldn't need to add this pusher with 200px margin.
I heard about that it can be done using flex 1 1 0% or something like that, I am not sure how to implement it.
body {
margin: 0;
}
.content {
display: flex;
}
.sidebar {
position: fixed;
left: 0;
width: 200px;
background: red;
height: 100vh;
overflow-y: auto;
}
.body {
background: blue;
flex: 1;
height: 100vh;
}
.pusher {
margin-right: 200px;
}
.nav{
background: yellow;
height: 60px;
}
<div class="content">
<div class="sidebar"></div>
<div class="pusher">
</div>
<div class="body">
<div class="nav">
Nav
</div>
test
</div>
</div>
Here you go...
I removed the div with class="pusher" and changed/added the CSS as follows:
.sidebar {
width: 20vw;
}
.body {
position: absolute;
width: 80vw;
right: 0;
}
Basically, I made the div class="sidebar" and the div with class="body" make up to 100 % of the screen but in different relative units, i.e. vw (20 vw + 80 vw = 100 vw). So, now I just needed to add right: 0; to the div with class="body" in order to achieve the exact same result as you did with margin-right: 200px;. I also added position: absolute; to the div with class="body", otherwise it won't work.
See the snippet below.
body {
margin: 0;
}
.content {
display: flex;
}
.sidebar {
position: fixed;
left: 0;
width: 20vw;
background: red;
height: 100vh;
overflow-y: auto;
}
.body {
position: absolute;
background: blue;
height: 100vh;
width: 80vw;
right: 0;
}
.nav {
background: yellow;
height: 60px;
}
<div class="content">
<div class="sidebar"></div>
<div class="body">
<div class="nav">Nav</div>
<div>test</div>
</div>
</div>
Hi I change your HTML and CSS code and I do my best for you.
HTML CODE:
<div class="main">
<div class="sidebar">This is Sidebar</div>
<div class="content">
<div class="nav">
Nav
</div>
<div class="content-body">
test
</div>
</div>
</div>
CSS Code:
body {
margin: 0;
}
.main{
display: flex;
width: 100vw;
}
.sidebar {
left: 0;
width: 200px;
background: red;
height: 100vh;
}
.content {
display: flex;
flex-direction: column;
width: 100vw;
background: #ddd;
height: 100vh;
}
.nav{
background: yellow;
height: 60px;
}
.content-body {
background: blue;
height: 100vh;
}
I am trying to split the screen horizontally into 3 equal pieces so I can place separate images into each piece. I have split the screen somewhat equally, but I am running into some issues with a white space and not being split equally.
Here is what I have:
HTML:
<div class="split left">
<div class="centered">
<img src="img_avatar2.png" alt="Avatar woman">
</div>
</div>
<div class="split center">
<div class="centered">
<img src="img_avatar.png" alt="Avatar man">
</div>
</div>
<div class="split right">
<div class="centered">
<img src="golf_course.jpg" alt="Finished Terrain Golf Course">
</div>
</div>
CSS:
/* Split the screen into thirds*/
.split {
height: 100%;
width: 33.3333%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
/* Control the left side */
.left {
left: 0;
background-color: #111;
}
/* Control the right side */
.right {
right: 0;
background-color: red;
}
.center {
right:auto;
left:auto;
background-color:wheat;
}
/* If you want the content centered horizontally and vertically */
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
/* Style the image inside the centered container, if needed */
.centered img {
width: 150px;
border-radius: 50%;
}
Image:
You can use flexbox:
.container {
display: flex;
justify-content: space-between;
}
.container div {
width: 100%;
padding: 5px;
border: 1px solid black;
}
<div class="container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
You can use grid :
https://css-tricks.com/snippets/css/complete-guide-grid/
in grid you can divide your grid.
*doesn"t work with older browsers like ie11
First, width: available is not valid property. if you want to use all available space you should set width: 100%. anyway, for solving your issue you should use height: 100% also for body and html. see this example:
body, html {
width: 100%;
height: 100%;
margin: 0;
}
.container {
width: 100%;
height: 100%;
}
.leftpane {
width: 33%;
height: 100%;
float: left;
background-color: rosybrown;
border-collapse: collapse;
}
.middlepane {
width: 33%;
height: 100%;
float: left;
background-color: royalblue;
border-collapse: collapse;
}
.rightpane {
width: 33%;
height: 100%;
position: relative;
float: right;
background-color: yellow;
border-collapse: collapse;
}
<div class="container">
<div class="leftpane">
<h1>Test Page</h1></div>
<div class="middlepane">Test Page</div>
<div class="rightpane">
<h1>Test Page</h1></div>
</div>
I have a section inside width: 1180px; i want to extend this green color div I want to make width: 100% I have tried using vw but not getting but some extra space is coming. can anyone suggest me? Is there any other way to do using CSS.
.wrapper {
width: 100%;
position: relative;
background: #ccc;
}
.inner {
width: 1180px;
margin: 0 auto;
background: pink;
}
.box1 {
height: 50px;
background: red;
}
.box2 {
height: 50px;
background: green;
margin-left: calc(-100vw/2 + 100%/2);
margin-right: calc(-100vw/2 + 100%/2);
width: 100vw;
}
<div class="wrapper">
<div class="inner">
<div class="box1"></div>
<div class="box2"></div>
</div>
</div>
You need to reset the margin using media query. Initially you have a negative margin but after 1180px it will be a positive one creating the unwanted space. You also don't need to set width using vw unit. Keeping the default width is enough:
.wrapper {
width: 100%;
position: relative;
background: #ccc;
}
.inner {
width: 1180px;
margin: 0 auto;
background: pink;
}
.box1 {
height: 50px;
background: red;
}
.box2 {
height: 50px;
background: green;
margin-left: calc(-100vw/2 + 100%/2);
margin-right: calc(-100vw/2 + 100%/2);
}
#media all and (max-width:1180px) {
.box2 {
margin:0;
}
}
<div class="wrapper">
<div class="inner">
<div class="box1"></div>
<div class="box2"></div>
</div>
</div>
You could use negative margin - the only problem with this approach is that if the page gets a vertical scroll, this will add a horizontal scroll as 100vw doesn't take into account the 20px caused by the vertical scroll:
body {
margin: 0;
}
.wrapper {
width: 100%;
position: relative;
background: #ccc;
}
.inner {
width: 1180px;
margin: 0 auto;
background: pink;
}
.box1 {
height: 50px;
background: red;
}
.box2 {
height: 50px;
background: green;
width: 100%;
}
#media screen and (min-width:1180px) {
.box2 {
margin: 0 calc(((100vw - 1180px) / 2) * -1);
width: auto;
}
}
<div class="wrapper">
<div class="inner">
<div class="box1"></div>
<div class="box2"></div>
</div>
</div>
As I say in my comments, it would be better to just move the green div outside your wrapper
.wrapper {
width: 100%;
position: relative;
background: #ccc;
}
.inner {
width: 1180px;
margin: 0 auto;
}
.box1 {
height: 50px;
background: red;
}
.box2 {
height: 50px;
background: green;
}
<div class="wrapper">
<div class="inner">
<div class="box1"></div>
<div class="box2"></div>
</div>
</div>
Try this:
.wrapper {
width: 100%;
position: relative;
background: #ccc;
}
.inner {
width: 1180px;
margin: 0 auto;
background: pink;
}
.box1 {
height: 50px;
background: red;
}
.box2 {
height: 50px;
background: green;
width: 100%;
}
<div class="wrapper">
<div class="inner">
<div class="box1"></div>
<div class="box2"></div>
</div>
</div>
I need to create one page with 4 elements: header, filter of elements, item list and item. But i can't to set div's without main page scroll. I want to have only one scroll bar - in item-list?
html,
body {
margin: 0;
height: 100%;
}
.header {
background-color: cadetblue;
height: 3em;
width: 100%;
}
.space {
width: 25em;
height: 100%;
}
.filter {
width: 100%;
height: 5em;
background-color: darkblue
}
.item-list {
height: 100%;
margin: 0.2em;
overflow: auto;
}
.item {
background-color: burlywood;
height: 20em;
width: 100%;
}
<body>
<div class="header"></div>
<div class="space">
<div class="filter"></div>
<div class="item-list">
<div class="item"></div>
<div class="item"></div>
</div>
</div>
</body>
Can anybody to help me with this?
You can use flex and overflow:
html,
body {
margin: 0;
height: 100%;
}
/* === flex update ====*/
body, .space {/* display:flex and overflow:hidden */
display:flex;
flex-direction:column;
overflow:hidden;
}
.space, .item-list {/* fill whole space avalaible */
flex:1;
}
.item-list {
overflow: auto;/* overflow ...*/
background:gray /* debug, see me */
}
/* === end flex update ====*/
.header {
background-color: cadetblue;
height: 3em;
}
.space {
width: 25em;
}
.filter {
width: 100%;
height: 5em;
background-color: darkblue
}
.item-list {
margin: 0.2em;
}
.item {
background-color: burlywood;
height: 20em;
width: 100%;
}
<div class="header"></div>
<div class="space">
<div class="filter"></div>
<div class="item-list">
<div class="item"></div>
<div class="item"></div>
</div>
</div>
You can avoid using Scroll on the main element by setting a static height on your header and using calc on your space element, just like the example..
html,
body {
margin: 0;
height: 100vh;
}
.header {
background-color: cadetblue;
height:20px;
width: 100%;
}
.space {
width: 25em;
height: calc(100% + -30px);
position:relative;
}
.filter {
width: 100%;
height: 20%;
background-color: darkblue
}
.item-list {
height: 80%;
margin: 0.2em;
overflow: auto;
}
.item {
background-color: burlywood;
height: 20em;
width: 100%;
}
<body>
<div class="header"></div>
<div class="space">
<div class="filter"></div>
<div class="item-list">
<div class="item"></div>
<div class="item"></div>
</div>
</div>
</body>
remove overflow:auto from .item-list
and make the .item class height 100% instead of 20em.
Hope this will full full your requirement.
I want to create a page like this:
and here is my HTML:
<div class="container">
<div class="article">
<div class="main-content">
Main content goes here...
</div>
<div class="content-meta">
<div class="content-title">
the title of content goes here...
</div>
<div class="content-info">
some information about content....
</div>
</div>
</div>
</div>
and CSS:
.container {
overflow:hidden;
position:relative;
width: 100%;
height: 350px;
}
.container .article {
width:100%;
position:absolute;
left:0;
top:0;
background-color: red;
}
.container .article .main-content {
width:50%;
float: right;
}
.container .article .content-meta {
width:50%;
float: right;
position: relative;
height: 350px;
}
.container .content-title , .container .content-info {
width: 100%;
position: absolute;
left: 0;
height: 50%;
}
.container .content-title {
background-color: green;
top: 0;
}
.container .content-info {
background-color: blue;
top: 50%;
}
it's working but when I use % instead of px for height of green and blue area, it just doesn't work. Why?
I mean, I set for both green and blue area height:50% but it didn't work. How can I solve this problem?
Note: I have 6 div.article elements and I want all of them to be stacked on top of each other and that's why I'm using position property.
In order to have percentage height to work you need to set both the parent elements .container .article .content-meta and .container .article to height:100%.
.container {
overflow: hidden;
position: relative;
width: 100%;
height: 350px;
}
.container .article {
width: 100%;
position: absolute;
left: 0;
top: 0;
background-color: red;
height: 100%;
}
.container .article .main-content {
width: 50%;
float: right;
}
.container .article .content-meta {
width: 50%;
float: right;
position: relative;
height: 100%;
}
.container .content-title,
.container .content-info {
width: 100%;
position: absolute;
left: 0;
height: 50%;
}
.container .content-title {
background-color: green;
top: 0;
}
.container .content-info {
background-color: blue;
top: 50%;
}
<div class="container">
<div class="article">
<div class="main-content">
Main content goes here...
</div>
<div class="content-meta">
<div class="content-title">
the title of content goes here...
</div>
<div class="content-info">
some information about content....
</div>
</div>
</div>
</div>
In fact, when you use absolute position, float won't be necessary.
.article {
position: relative;
height: 350px;
}
.main-content {
position: absolute;
left: 50%;
top: 0;
width: 50%;
height: 100%;
background: red;
}
.content-meta {
position: absolute;
left: 0;
top: 0;
width: 50%;
height: 100%;
}
.content-title,
.content-info {
position: absolute;
left: 0;
width: 100%;
height: 50%;
}
.content-title {
background: green;
top: 0;
}
.content-info {
background: blue;
top: 50%;
}
<div class="article">
<div class="main-content">
Main content goes here...
</div>
<div class="content-meta">
<div class="content-title">
the title of content goes here...
</div>
<div class="content-info">
some information about content....
</div>
</div>
</div>
Or, just use float without absolute position.
.article {
height: 350px;
}
.main-content {
float: right;
width: 50%;
height: 100%;
background: red;
}
.content-meta {
float: left;
width: 50%;
height: 100%;
}
.content-title,
.content-info {
float: left;
width: 100%;
height: 50%;
}
.content-title {
background: green;
}
.content-info {
background: blue;
}
<div class="article">
<div class="main-content">
Main content goes here...
</div>
<div class="content-meta">
<div class="content-title">
the title of content goes here...
</div>
<div class="content-info">
some information about content....
</div>
</div>
</div>
Alternatively, you can use flexbox if you don't need to support old browsers.
.article {
height: 350px;
display: flex;
flex-direction: row-reverse;
}
.main-content {
background: red;
flex: 1;
}
.content-meta {
flex: 1;
display: flex;
flex-direction: column;
}
.content-title,
.content-info {
flex: 1;
}
.content-title {
background: green;
}
.content-info {
background: blue;
}
<div class="article">
<div class="main-content">
Main content goes here...
</div>
<div class="content-meta">
<div class="content-title">
the title of content goes here...
</div>
<div class="content-info">
some information about content....
</div>
</div>
</div>