Create 6 boxes with css - css

I really need some help with some easy css that I just can't get my head around.
I want to create boxes like in the link below.
I guess I could have the code for just one of them, and then use it over and over again, but how do I create the boxes so that they don't mind the other stuff around them?
Example here: http://s23.postimg.org/qypbfvv0r/boxes.jpg

Here: I have figured out a way of doing this. I hope that this helps you in some way in helping you figure out how to finish your task.
HTML:
<div class="containers">
<p class="heading">Heading</p>
<div class="inner1"></div>
<div class="inner2"></div>
</div>
<div class="containers">
<p class="heading">Heading</p>
<div class="inner1"></div>
<div class="inner2"></div>
</div>
<div class="containers">
<p class="heading">Heading</p>
<div class="inner1"></div>
<div class="inner2"></div>
</div>
CSS:
.containers {
width: 300px;
height: 150px;
border: 1px solid black;
margin-bottom: 10px;
overflow: hidden;
position: relative;
}
.inner1 {
margin-left: 5px;
width: 135px;
height: 80px;
border: 1px solid black;
background-color: blue;
}
.inner2 {
position: relative;
float: right;
top: -60%;
margin-left: 5px;
margin-right: 5px;
width: 135px;
height: 80px;
border: 1px solid black;
background-color: red;
}
.heading {
padding-left: 20px;
}

You can start off using this code. After this you can give border styles and colors to the individual divs.
<div>
<div style="float:right"> Content </div>
<div style="float:left"> Content </div>
</div>
<div style="padding-top:10px">
<div style="float:right"> Content </div>
<div style="float:left"> Content </div>
</div>
<div style="padding-top:10px">
<div style="float:right"> Content </div>
<div style="float:left"> Content </div>
</div>
Hope this helps

Related

Place float elements in a row in div container

I'm trying to place a calender inside a transparent div container, however I'm having some issues, i want each calender box to form a row that takes up 100% in width in the transparent box. So basically at the moment the page looks like this:
screenshot.
What you probably noticed is if you look at container with the "click on the images text" is that the box is wider than the rows under it.
This is the CSS code for the calender: Basically everything relating to .transbox has something to do with the transparent box. The calender days are the classes .weekdayssttart and weekdays. The remaining classes are the calender days with numbering. So since there is 7 days a week i just thought that I had to divide 100/7 which is 14.2857142857 and set each box type to that width in percentage. However this is the result i get: screenshot2. What I obviously notice is that the row is to small to contain the calender boxes, does anyone have an idea to fix this? Sorry for my bad english.
.transbox {
background: #fff;
padding: 2%;
width: 70%;
margin-left: 15%;
margin-bottom: 1%;
position: relative;
background-color:rgba(255,255,255,.9);
border-radius: 5px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,.9);
overflow: auto;
}
.transbox p {
color: darkslategray;
margin-bottom: 2%;
font-size:13px;
}
.transbox img {
width:100%;
height: 100%;
}
.weekdaysstart {
width: 14%;
height: 20px;
background-color:floralwhite;
border: 1px solid darkslategrey;
text-align:center;
float: left;
}
.weekdays {
width: 14%;
height: 20px;
background-color:floralwhite;
border: 1px solid darkslategrey;
text-align:center;
float: left;
}
.hint {
width: 99%;
height: 20px;
background-color:floralwhite;
border: 1px solid darkslategrey;
text-align:center;
padding-top: 5px;
}
.one {
background-color: floralwhite;
width: 14%;
height: 100px;
float: left;
border: 1px solid darkslategrey;
color: darkslategrey;
}
.nextrow {
background-color: floralwhite;
width: 14%;
height: 100px;
float: left;
clear:left;
border: 1px solid darkslategrey;
color: darkslategrey;
}
.nextmonth {
background-color: floralwhite;
width: 14%;
height: 100px;
float: left;
border: 1px solid darkslategrey;
color: darkslategrey;
}
.lastrow {
width: 14%;
height: 100px;
float: left;
border: 1px solid darkslategrey;
color: darkslategrey;
background-color: floralwhite;
margin-bottom:2%;
}
.pancakes {
width: 14%;
height: 100px;
float:left;
background: url(images/pancakes.jpeg);
background-size: cover;
border: 1px solid darkslategrey;
}
.meatballs {
width: 14%;
height: 100px;
float:left;
border: 1px solid darkslategrey;
background: url(images/kotbulls.jpg);
background-size: cover;
}
<!DOCTYPE html>
<html>
<head>
<title>Tasty recipes</title>
<link href="reset.css" rel="stylesheet" type="text/css">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body>
<ul>
<li>HOME</li>
<li>RECIPES</li>
<li>CALENDAR</li>
<li class="tastyrecipes">Tasty Recipes</li>
</ul>
<h1>Calendar</h1>
<h3>November 2017</h3>
<div class = "transbox">
<div class="hint">
<p>Click on the image of a dish to go to its recipe-page.</p>
</div>
<div class="weekdaysstart">
<p>Monday</p>
</div>
<div class="weekdays">
<p>Tuesday</p>
</div>
<div class="weekdays">
<p>Wednesday</p>
</div>
<div class="weekdays">
<p>Thursday</p>
</div>
<div class="weekdays">
<p>Friday</p>
</div>
<div class="weekdays">
<p>Saturday</p>
</div>
<div class="weekdays">
<p>Sunday</p>
</div>
<div class="nextrow">
<p>30</p>
</div>
<div class="one">
<p>31</p>
</div>
<div class="one">
<p>1</p>
</div>
<div class="one">
<p>2</p>
</div>
<div class="one">
<p>3</p>
</div>
<div class="one">
<p>4</p>
</div>
<div class="one">
<p>5</p>
</div>
<div class="nextrow">
<p>6</p>
</div>
<a href="meatballs.html">
<div class="meatballs">
<p>7</p>
</div>
</a>
<div class="one">
<p>8</p>
</div>
<div class="one">
<p>9</p>
</div>
<div class="one">
<p>10</p>
</div>
<div class="one">
<p>11</p>
</div>
<div class="one">
<p>12</p>
</div>
<div class="nextrow">
<p>13</p>
</div>
<div class="one">
<p>14</p>
</div>
<div class="one">
<p>15</p>
</div>
<div class="one">
<p>16</p>
</div>
<div class="one">
<p>17</p>
</div>
<div class="one">
<p>18</p>
</div>
<div class="one">
<p>19</p>
</div>
<div class="nextrow">
<p>20</p>
</div>
<div class="one">
<p>21</p>
</div>
<div class="one">
<p>22</p>
</div>
<div class="one">
<p>23</p>
</div>
<div class="one">
<p>24</p>
</div>
<a href="pancakes.html">
<div class="pancakes">
<p>25</p>
</div>
</a>
<div class="one">
<p>26</p>
</div>
<div class="nextrow">
<p>27</p>
</div>
<div class="lastrow">
<p>28</p>
</div>
<div class="lastrow">
<p>29</p>
</div>
<div class="lastrow">
<p>30</p>
</div>
<div class="nextmonth">
<p>1</p>
</div>
<div class="nextmonth">
<p>2</p>
</div>
<div class="nextmonth">
<p>3</p>
</div>
</div>
</body>
</html>
Like Matthew JohnSon said, you could do this using flexbox. I'm not totally sure, but I believe the calc() function will let it fit.
.transbox {
width: 100%;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
}
.weekdaysstart, .weekdays {
width: calc(100% / 7);
}
Edit
I changed the names of the classes to those of your html classes.
You should use a clearfix container per each row.
https://css-tricks.com/snippets/css/clear-fix, and try to use flex instead of float, set each .row display: flex, and then set flex-grow: 1; flex-shrink: 1; flex-basis: auto; to the elements inside the row.

Resizable containers at the same level

<div class="row container-row">
<div class="col-md-8 col-xs-12 no-padding-column">
<div class="video-container">
<img class="video-image" src="image.jpg">
<a href="#" class="js-play-video">
<img class="play-image" src="play.png">
</a>
</div>
</div>
<div class="col-md-4 col-xs-12 no-padding-column">
<div class="text-content">
<h1>Superious Quality</h1>
<p>sometext</p>
</div>
</div>
</div>
Below is my Style
.panel-container {
color: #fff;
height: auto;
position: relative;
margin: 0px auto;
}
.panel-container .container-row {
margin: 5%;
}
.panel-container .container-row .no-padding-column {
padding-right: 0px;
padding-left: 0px;
}
.panel-container .video-container {
display: block;
position: relative;
}
.panel-container .video-container .video-image {
width: 100%;
}
.panel-container .play-image {
position: absolute;
width: 13%;
height: auto;
top: 50%;
left: 57%;
margin-left: -12%;
margin-top: -6%;
}
.panel-container .text-content {
padding-left: 15px;
padding-right: 15px;
float: left;
height: 381px;
background-color: rgba(0, 0, 0, 0.6);
color: #fff;
}
#media (max-width: 30em) {
.panel-container .text-content {
height: auto;
}
}
.panel-container .text-content h1 {
color: #fff;
}
I want the text-content has the same height as the video-container. Please note that the height of video-container is not fixed and defined by the size of image and it's resizing when the browser resize. How can I make the text-content resizable to always be aligned (height) with the video-container?
One solution would be to make the .container-row and the .text-content the same background-color. The code:
.panel-container {
color: #fff;
margin: 0px auto;
}
.panel-container .container-row {
background: #666666;
margin: 5%;
}
.panel-container .container-row .no-padding-column {
padding-right: 0px;
padding-left: 0px;
}
.panel-container .video-container .video-image {
width: 100%;
}
.panel-container .play-image {
position: absolute;
width: 13%;
height: auto;
top: 50%;
left: 57%;
margin-left: -12%;
margin-top: -6%;
}
.panel-container .text-content {
padding: 0 15px;
float: left;
color: #fff;
}
.panel-container .text-content h1 {
color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid panel-container">
<div class="row container-row">
<div class="col-xs-8 no-padding-column">
<div class="video-container">
<img class="video-image" src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" />
<a href="#" class="js-play-video">
<img class="play-image" src="http://uxrepo.com/static/icon-sets/iconic/svg/play-circle2.svg" />
</a>
</div>
</div>
<div class="col-xs-4 no-padding-column">
<div class="text-content">
<h1>Superious Quality</h1>
<p>sometext</p>
</div>
</div>
</div>
</div>
I know it is not the right way to do it and that it doesn't answer the question, but it works on behaviour.
I actually used the Reflex on a link but it's not used extensively. I'm not sure if it's a right thing to use to get the site to production. Please let me know if there is any better option.
To adjust both divs at the same height, all I did was adding
float: left;
to the css class .no-padding-column
.panel-container .container-row .no-padding-column {
padding-right: 0px;
padding-left: 0px;
float: left;
}
I tried to reproduce your situation in a fiddle. Notice that I removed the .panel-container class, since it's not in your code. I am not sure where this class is, it might cause problems as well, let me know if my Fiddle works as exspected. And if there's still a problem, could you add your .panel-container class as well? (And maybe images from the internet and not local ones? That would make it much easier for us)
For those who want to adjust the height of the second div, depending on the change of the first div:
For this you could use the JS framework "attrchange". Add the JS file to your page and use the following code.
$(".video-container").attrchange({
trackValues: true, // set to true so that the event object is updated with old & new values
callback: function(event) {
if(event.attributeName == "height") { // which attribute you want to watch for changes
$(".text-content").css('height', event.newValue);
}
}
});
I post the solution I found you might be interested as well.
Here is codepen link!
<div class="table-wrapper">
<div class="table-row">
<div class="table-column short-column">
<div class="content-container">
<p>Short Column</p>
</div>
<div class="button-row">
<button>Click Me</button>
</div>
</div>
<div class="table-column medium-column">
<div class="content-container">
<p>Medium Column</p>
<p>Medium Column</p>
<p>Medium Column</p>
</div>
<div class="button-row">
<button>Click Me</button>
</div>
</div>
<div class="table-column long-column">
<div class="content-container">
<p>Long Column</p>
<p>Long Column</p>
<p>Long Column</p>
<p>Long Column</p>
<p>Long Column</p>
<p>Long Column</p>
<p>Long Column</p>
</div>
<div class="button-row">
<button>Click Me</button>
</div>
</div>

How to make a horizontal line?

Hi so here's what I want to do,
http://i1377.photobucket.com/albums/ah45/nikilean/line_zpswvrndxwg.jpg
a horizontal line behind the images? There are 8 circles and I want them to be connected with a line
I made it in bootstrap so the lines are divided into two col 6 and inside each col there are 3 col-3
.stepnumber {
height: 30px;
width: 30px;
border-radius: 50%;
background-color: #f9b315;
vertical-align: middle;
color: #fff;
padding-top: 2px;
padding-right: 10px;
font-size: 18px;
font-weight: bold;
margin-top: 150px;
left: -10px;
}
.step {
height: 150px;
width: 150px;
border-radius: 50%;
background-color: #fff;
margin-top: 80px;
margin-right:-60px;
position: absolute;
}
<div class="container">
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<div class="lineline"><div class=stepnumber>1</div></div>
</div>
<div class="col-md-3">
<div class="step">
<div class="workstitle">
BOOK
</div>
</div>
</div>
<div class="col-md-3">
<div class=stepnumber>2</div>
</div>
<div class="col-md-3">
<div class="step">
<div class="workstitle">
WAIT
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<div class=stepnumber>3 </div>
</div>
<div class="col-md-3">
<div class="step">
<div class="workstitle">
FOUND
</div>
</div>
</div>
<div class="col-md-3">
<div class=stepnumber>4</div>
</div>
<div class="col-md-3">
<div class="step">
<div class="workstitle">
FLY!
</div>
</div>
</div>
</div>
</div>
</div>
You can achieve the look you're going for by using the :after (or :before) pseudo class on your wrapping element. You can create a border on the :after element and position it behind your circles using z-index.
Below is an example of how you could construct it.
.timeline {
height: 150px;
line-height: 150px;
display: table;
position: relative;
}
.timeline:after {
position: absolute;
left: 0.5em;
right: 0.5em;
top: 50%;
content: "";
border-top: 3px solid #F9B315;
z-index: 900;
}
.-item {
display: table-cell;
vertical-align: middle;
z-index: 1000;
position: relative;
}
.-item > div {
margin-left: 0.5em;
margin-right: 0.5em;
width: 150px;
height: 150px;
border-radius: 50%;
text-align: center;
line-height: 150px;
font-weight: bold;
font-size: 18px;
background-color: #f9b315;
color: #FFF;
}
.-item:first-of-type > div { margin-left: 0; }
.-item:last-of-type > div { margin-right: 0; }
.-item._number > div {
width: 30px;
height: 30px;
line-height: 2;
}
<div class="timeline">
<div class="-item _number">
<div>1</div>
</div>
<div class="-item _title">
<div>BOOK</div>
</div>
<div class="-item _number">
<div>2</div>
</div>
<div class="-item _title">
<div>WAIT</div>
</div>
<div class="-item _number">
<div>3</div>
</div>
<div class="-item _title">
<div>FOUND</div>
</div>
<div class="-item _number">
<div>4</div>
</div>
<div class="-item _title">
<div>FLY!</div>
</div>
</div>
This is going to take a little bit of work on your part, but here is a way to put a horizontal line behind the div.
Here is the fiddle. The trick for the line is to make a div that's only 1px high. It will take a little bit of thinking on your part:
.line{
height: 1px;
width: 100px;
background-color: black;
z-index: 1;
position: absolute;
top: 25px;
}

three divs next to each other with two rows (six divs in total). if I do float they all go in one row

So I got a question about DIVs. I want 2 rows with 3 divs in each, centered. But the problem is if I do clear: left; all 6 will be next o eachother. Here is how my code looks like right now and I hope you can help me out.
CSS:
.row1 {
position: absolute;
height: 270px;
}
.row2 {
position: absolute;
height: 270px;
}
.columns {
width: 190px;
height: 274;
border-top: 1px solid #EBEBEB;
border-right: 1px solid #EBEBEB;
padding-top: 25px;
padding-right: 15px;
padding-bottom: 25px;
padding-left: 15px;
}
Here is my HTML:
<div id="row1">
<div class="columns"> </div>
<div class="columns"> </div>
<div class="columns"> </div>
</div>
<div id="row2">
<div class="columns"> </div>
<div class="columns"> </div>
<div class="columns"> </div>
</div>
this is one div:
head text
paragraph text
They are all floating next to each other. You should add a clear row where you want to seperate them. We usually call it clearfix.
<style>
.clearfix{ clear:both; }
</style>
</div>
<div class="clearfix"></div>
<div id="row2">
Try to use "display: inline-block" instead of float and remove "position: absolute". Add closing divs for the columns. And change css for the rows to refer to id, not class.
CSS:
.columns {
display: inline-block;
width: 190px;
border-top: 1px solid #EBEBEB;
border-right: 1px solid #EBEBEB;
}
#row1 {
height: 270px;
}
#row2 {
height: 270px;
}
HTML:
<div id="row1">
<div class="columns">1.1</div>
<div class="columns">1.2</div>
<div class="columns">1.3</div>
</div>
<div id="row2">
<div class="columns">2.1</div>
<div class="columns">2.2</div>
<div class="columns">2.3</div>
</div>
JsFiddle: http://jsfiddle.net/a5vKH/1/

The basic style for make this layot

It looks like a table, but I'd like to implement it by using only CSS.
What is the most robust style for this layout that works with all browser?
_________
| A |__b__|
|_A_|__c__|
<div class='container'>
<div class='sectA'> A </div>
<div>
<div class="sectB"> b </div>
<div class="sectC"> c </div>
</div>
</div>
You need one more div and two more classes, but it's very easy:
HTML
<div class='container'>
<div class='sectA'> A </div>
<div class="separator">
<div class="sectB"> b </div>
<div class="sectC"> c </div>
</div>
<div class="clear"> </div>
</div>
CSS:
.container div.sectA
{
float: left;
width: 100px;
height: 100px;
border: 1px dotted #000;
}
div.separator
{
float: left;
}
div.sectB,
div.sectC
{
float: none;
width: 100px;
height: 50px;
border: 1px dotted #f00;
}
.clear
{
clear: both;
}
Click here for an example.

Resources