How to make float bottom? - html

Demo is like this : https://jsfiddle.net/oscar11/9syLgw9m/3/
My code is like this :
<table border="2" width="650px">
<tr>
<td>
<div style="float:left">
<!-- <p style="text-align:center;"> -->
<img style="width:200px; height:140px; margin:9px;" src="http://img.thesun.co.uk/aidemitlum/archive/02388/Chelsea_Small_2388014a-660.png" />
<!-- </p> -->
</div>
<div style="float:left">
<div class="hotel">Nana hotel</div>
<div class="description">Nana hotel is the best.Nana hotel is the best.Nana hotel is the best.</div>
<div class="price" style="">
<div style="float:left;color:#c80000;font-size:16px;">Price : <b>123</b> / night</div>
<div style="float:right;"><button type="button" class="btn blue more">Detail</button> <button type="button" class="btn blue more">More</button></div>
</div>
</div>
</td>
</tr>
</table>
I want to show class "price" at the very bottom . Actually it can use the margin, but the problem is the class description, class description is the dynamic
How to make class "price" at the very bottom?
Thank you

First, please don't use <table> when you're not using tabular data.
That said, you can add padding-bottom to your .description and set the .price to position: absolute; and position it in the left bottom corner. The padding-bottom is the space that the price comes in, so play around to your needs. See my example below.
table {
position: relative;
}
.description {
padding-bottom: 20px;
}
.price {
position: absolute;
bottom: 0;
left: 0;
}
<table border="2" width="650px">
<tr>
<td>
<div style="float:left">
<!-- <p style="text-align:center;"> -->
<img style="width:200px; height:140px; margin:9px;" src="http://img.thesun.co.uk/aidemitlum/archive/02388/Chelsea_Small_2388014a-660.png" />
<!-- </p> -->
</div>
<div style="float:left">
<div class="hotel">Nana hotel</div>
<div class="description">Nana hotel is the best.Nana hotel is the best.Nana hotel is the best. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nesciunt, modi ipsum natus provident molestias magni culpa ab cumque, quo, deleniti fugiat adipisci sequi suscipit
porro maiores! Quod quibusdam modi consectetur!</div>
<div class="price" style="">
<div style="float:left;color:#c80000;font-size:16px;">Price : <b>123</b> / night</div>
<div style="float:right;">
<button type="button" class="btn blue more">Detail</button>
<button type="button" class="btn blue more">More</button>
</div>
</div>
</div>
</td>
</tr>
</table>
Edit
Here's a better solution, without using tables. Check out the code below and play around with it to your needs. display: flex; is the way to turn your 'design' easily in to what you want.
Please consider that in the future you need to do your own work. We're not employees ready to do whatever you want.
.description {
padding-bottom: 20px;
}
.container {
width: 650px;
border: 2px solid black;
display: flex;
flex-flow: row wrap;
}
.image {
width: 200px;
flex-basis: 200px;
}
.image img {
width: 200px;
}
.content {
flex-basis: calc(100% - 200px);
padding-left: 10px;
box-sizing: border-box;
}
.info-container {
display: flex;
flex-flow: row-wrap;
justify-content: flex-start;
}
.price {
color: #c80000;
font-size: 16px;
}
.buttons {
margin-left: auto;
}
<div class="container">
<div class="image">
<img src="http://img.thesun.co.uk/aidemitlum/archive/02388/Chelsea_Small_2388014a-660.png" alt="Chelsea" />
</div>
<div class="content">
<div class="title">Nana hotel</div>
<div class="description">Nana hotel is the best.Nana hotel is the best.Nana hotel is the best.</div>
<div class="info-container">
<div class="price">Price : <strong>123</strong> / night</div>
<div class="buttons">
<button type="button" class="btn blue more">Detail</button>
<button type="button" class="btn blue more">More</button>
</div>
</div>
</div>
</div>

Related

make the text take up as much space as the picture in grid with

i'm working on a school project where im supposed to do a portfolio. im trying to make a grid with pictuers and information next to that picture about stuff i have worked on. I'm trying to get the textbox to be as big as the picture. I have tried jusing flexbox and a lot of other stuff but can't get it to work. is there someone who can help me?
*{
box-sizing: border-box;
}
body{
background-color: #f4f4f4;
padding: 20px;
font-family: Arial;
}
.container {
max-width: 1600px;
margin: 0 auto;
}
.row {
margin:8px-16px;
}
.row,
.row > .column {
padding:2px 0px;
}
.column {
float:left;
width:50%;
}
.row:after {
content:"";
display:table;
clear:both;
}
.content {
background-color: white;
padding: 10px;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width:100%;
}
}
<div class="container">
<div class="row">
<div class="column">
<div class="content">
<h3>Hemsida 1</h3>
<p>Lorem ipsum.</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="atleta1.jpg" style="width:100%">
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="content">
<img src="atleta1.jpg" style="width:100%">ยด
</div>
</div>
<div class="column">
<div class="content">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
</div>
</div>
<div class="row">
<div class="column">
<div class="content">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
</div>
<div class="column">
<div class="content">
<img src="atleta1.jpg" style="width:100%">
</div>
</div>
</div>
</div>
You have complicated the layout very much. How do you like this layout option?
Each line is divided into two parts of 50%.
A small bonus: with small screens, due to the Flexbox property order, the description block is located above the picture.
P.S. Of course, this is not the final option. You can continue to improve it
Result
* {
box-sizing: border-box;
}
body {
background-color: #f4f4f4;
padding: 20px;
font-family: Arial;
}
.container {
max-width: 1600px;
margin: 0 auto;
padding: 0;
list-style: none;
}
.item {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
;
padding: 10px;
background-color: white;
}
.item__desc {
flex-basis: 50%;
}
.item__pic {
flex-basis: 50%;
}
.item_img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.item {
flex-direction: column;
width: 100%;
}
.item__desc {
order: -1;
}
}
<ul class="container">
<li class="item">
<div class="item__desc">
<h3>Hemsida 1</h3>
<p>Lorem ipsum.</p>
</div>
<div class="item__pic">
<img class="item_img" src="https://picsum.photos/536/354"></div>
</li>
<li class="item">
<div class="item__pic">
<img class="item_img" src="https://picsum.photos/536/354">
</div>
<div class="item__desc">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
</li>
<li class="item">
<div class="item__desc">
<h3>Hemsida 2</h3>
<p>Lorem ipsum.</p>
</div>
<div class="item__pic">
<img class="item_img" src="https://picsum.photos/536/354"></div>
</li>
</ul>
And same code on CodePen
will be enough for homework. Edit and improve codes
*{
margin: 0;
padding: 0;
box-sizing:border-box;
}
.box{
margin-bottom:20px;
background: #3498db;
height:500px;
}
.box-left{
width:50%;
float:left;
height:500px;
padding:50px;
}
.box-left h3{
margin-bottom: 15px;
}
.box-right{
width:50%;
float:right;
height:500px;
}
.box-right img{
width:100%;
height:100%;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="box">
<div class="box-left">
<h3>Head</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequuntur quas a velit. Aut nihil, modi nobis corporis eveniet ratione aperiam repellat maiores corrupti quidem ipsam animi officiis, fugit quasi rem!</p>
</div>
<div class="box-right">
<img src="https://i.ibb.co/S6PdtwP/69037904-2403297686584790-2753464427788369920-n.jpg" alt="">
</div>
</div>
<div class="box">
<div class="box-left">
<h3>Head</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequuntur quas a velit. Aut nihil, modi nobis corporis eveniet ratione aperiam repellat maiores corrupti quidem ipsam animi officiis, fugit quasi rem!</p>
</div>
<div class="box-right">
<img src="https://i.ibb.co/S6PdtwP/69037904-2403297686584790-2753464427788369920-n.jpg" alt="">
</div>
</div>
</body>
</html>
live demo
codepen live demo

Stretch div dependence of content

I want stretch box dependence of content, i'm using flexbox, but i can't to do. Below link my example
Parent div
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-content: stretch;
Child div
order: 0;
flex: 0 1 auto;
align-self: auto;
.slick-track {
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-content: stretch;
}
.slick-slide {
width: 150px;
margin: 10px;
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.sliderItem {
overflow: hidden;
background: #2F2F2F;
color: #fff;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
cursor: pointer;
}
.sliderItemTitle {
font-size: 25px;
font-weight: bold;
padding: 20px 20px 0;
min-height: 84px;
}
.sliderItemText {
display: flex;
padding-top: 10px;
padding: 0px 20px;
min-height: 58px;
align-items: center;
}
.sliderItemLinkBox {
margin-bottom: 20px;
padding: 0 20px;
}
.sliderItemLink {
color: yellow;
text-transform: uppercase;
}
<div class="slick-track">
<div class="slick-slide">
<div>
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 1</strong>
</div>
<div class="sliderItemText">
lorema dadad addadadad adadadadadasd
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div>
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 2</strong>
</div>
<div class="sliderItemText">
Lorem
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div>
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 3</strong>
</div>
<div class="sliderItemText">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta dolore ipsa at minus molestias, neque rerum, aut minima voluptatum, dolorem odit nesciunt aliquid ullam officia reiciendis, recusandae natus maxime beatae.
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
</div>
https://jsfiddle.net/7qvo2tmk/5/
This can be accomplished using JS to loop through the elements and adjust the height based on the tallest element.
Working Example
let slides = document.querySelectorAll('.sliderItem')
function updateHeights() {
let tallestSlide = 0
for (i = 0; i < slides.length; i++) {
if (slides[i].clientHeight > tallestSlide) {
tallestSlide = slides[i].clientHeight
}
}
for (i = 0; i < slides.length; i++) {
slides[i].style.height = tallestSlide + 'px'
}
}
window.onresize = updateHeights
updateHeights()
You can try doing this.
What I did is that I remove the div that encloses the .sliderItem
and then add height to the .sliderItem of height:100%. so that it will occupy the height of its parent div .slick-slide.
.slick-track {
display: flex;
flex-wrap: nowrap;
justify-content: center;
align-content: stretch;
}
.slick-slide {
width: 150px;
margin: 10px;
order: 0;
flex: 0 1 auto;
align-self: auto;
}
.sliderItem {
height: 100%;
overflow: hidden;
background: #2F2F2F;
color: #fff;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
cursor: pointer;
}
.sliderItemTitle {
font-size: 25px;
font-weight: bold;
padding: 20px 20px 0;
min-height: 84px;
}
.sliderItemText {
display: flex;
padding-top: 10px;
padding: 0px 20px;
min-height: 58px;
align-items: center;
}
.sliderItemLinkBox {
margin-bottom: 20px;
padding: 0 20px;
}
.sliderItemLink {
color: yellow;
text-transform: uppercase;
}
<div class="slick-track">
<div class="slick-slide">
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 1</strong>
</div>
<div class="sliderItemText">
lorema dadad addadadad adadadadadasd
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 2</strong>
</div>
<div class="sliderItemText">
Lorem
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
<div class="slick-slide">
<div class="sliderItem">
<div class="sliderItemImg">
<img src="https://via.placeholder.com/150" alt="">
</div>
<div class="sliderItemTitle">
<strong>Title 3</strong>
</div>
<div class="sliderItemText">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta dolore ipsa at minus molestias, neque rerum, aut minima voluptatum, dolorem odit nesciunt aliquid ullam officia reiciendis, recusandae natus maxime beatae.
</div>
<div class="sliderItemLinkBox">
<div class="sliderItemLink">
click
</div>
</div>
</div>
</div>
</div>
Hope this helps

How can I display image behind div with bootstrap?

I have 2 rows in my container. In the second row I have 2 elements one and two. Now I am trying to display the image behind those too almost like a background. This is the html:
<div class="container">
<div class="row">
<img src="someimageurl" alt="" />
</div>
<div class="row">
<div class="col-md-6">one</div>
<div class="col-md-6">two</div>
</div>
</div>
codepen
Check if his works for you.
CSS:
.container{
border: 4px solid red;
position: relative;
overflow: hidden;
}
.contentBox {
min-height: 300px
}
.imgBox {
position: absolute;
top: 0;
let: 0;
width: 100%;
z-index: -1;
}
.imgBox img {
width: 100%;
margin: 0;
}
HTML:
<div class="container">
<div class="row contentBox">
<div class="col-md-6">one</div>
<div class="col-md-6">two</div>
</div>
<div class="imgBox row">
<img src="imageURL.jpg" alt="" />
</div>
</div>
enter link description here
Is background-image what you're looking for?
HTML
<div id=RowDivWithBackground class=row>
</div>
CSS
.RowDivWithBackground {
background-image: url('url/to/image');
other-css-do-dads /*Probably some rgba action*/
}
use css to do that
#{your div ID}{
background-image: url("backgroundImage.png");
}
i think this may be help you
try this code
html
<div class="row">
<div class="bg clearfix">
<div class="col-md-6">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusantium optio itaque quas ab facere, ipsa cumque consequatur nam id voluptatibus numquam, sapiente suscipit doloremque blanditiis non, ipsam sint vel molestias.</div>
<div class="col-md-6">two</div>
</div>
</div>
css
.bg
{
background-image:url(http://data.whicdn.com/images/12849966/large.jpg);
background-position:center;
background-size:cover;
}
hope it helps
If you really need to use the img-tag, try to use position: fixed and z-index: -1 (or -2, -3, ...)
.container {
border: 4px solid red;
position: relative;
}
#imageAsBackground {
z-index: -1;
position: fixed;
}
<div class="container">
<div class="row">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWTPbXeQy0Sy6xCbSwL_Vc4oQtMS-UNkUPOwRb3TxWHKKNlZ5Ycg" id="imageAsBackground" alt="" />
</div>
<div class="row">
<div class="col-md-6">one</div>
<div class="col-md-6">two</div>
</div>
</div>
If you could use the image as a real background, try to use css for this then.
Like
.container{
border: 4px solid red;
}
.coolBackground {
background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWTPbXeQy0Sy6xCbSwL_Vc4oQtMS-UNkUPOwRb3TxWHKKNlZ5Ycg");
background-size: cover;
}
<div class="container">
<div class="row coolBackground">
<div class="col-md-6">one</div>
<div class="col-md-6">two</div>
</div>
</div>
background-size: cover; will adjust the image to the width of your div.

How design an unordered list of images horizontally with Bootstrap?

I am a new web designer and I am struggling right now in designing unordered list of icons to be displayed horizontally without the bullet.
Here's my html code:
<section id="call-to-action" class="section-padding">
<div data-velocity="-.3" class="overlay-bg cta-bg"></div>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="cta-text text-center">
<h2>Call to action</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eius labore itaque, nam eaque aut repellat ratione nesciunt explicabo numquam sit.</p>
<div class="partners">
<ul style="list-style: none;">
<li>
<img class="img-responsive"
title="Illustrator" alt="Illustrator"
src="../Assets/img/software/illustrator_icon.png" />
<img class="img-responsive"
title="Photoshop" alt="Photoshop"
src="../Assets/img/software/photoshop_icon.png" />
<img class="img-responsive"
title="InDesign" alt="InDesign"
src="../Assets/img/software/inDesign_icon.png" />
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- End call to action -->
CSS Code:
#call-to-action {
position: relative;
}
.section-padding {
padding: 50px 0;
}
.partners ul {
list-style: none;
margin: 0;
padding: 0;
}
.partners ul li {
display: inline-block;
float: left;
width: 20%;
}
Here's the link to JSFiddle that includes all of my code: https://jsfiddle.net/nta1qov2/
Could you please tell me how I can do this?
you can try this one:
#call-to-action {
position: relative;
}
.section-padding {
padding: 50px 0;
}
.partners ul {
list-style: none;
margin: 0;
padding: 0;
}
.partners ul li {
display: inline-block;
float: left;
/*width:20%; remove width 20% ;*/
width: 100%; /* add width :100%;*/
}
DEMO HERE
Add this css code":
.partners ul li {
position: absolute;
text-align:center;
display: inline-block;
width: 100%;
}
[UPDATED DEMO HERE]2
If you wish to do it through only twitter-bootstrap, then the following code illustrates the same:
HTML:
<div class="form-group">
<div class="pull-left control-label">
<img src="../img1.jpg" />
</div>
<div class="pull-left control-label">
<img src="../img2.jpg" />
</div>
<div class="pull-left control-label">
<img src="../img3.jpg" />
</div>
</div>
<div class="clearfix"></div>
Here, pull-left, is to make unordered horizontal list.
control-label for right indentation.
form-group for vertical indentation.
clearfix for nullifying the float as a result of pull-left after completion.

Centering divs without increasing their size & keeping the header together with the text?

I realize that I am asking two separate questions here, but given my inexperience with HTML and CSS, I get the feeling that they are connected. If nothing else, I am unsure about how to ask one question while ensuring that the answers I get will be compatible with the other.
So, here goes:
I am making a small calculator, which needs to look nice in different window sizes. I have some groupings of buttons that all need to be kept together, while the different groupings are moved around according to the window size. Below is a screenshot of "good behavior":
The content is together with headers, and there are no odd blank spaces.
Then we get the next behavior: upon a small change of window width, some material is moved down, but not the entire div - the header stays:
How do I make the header follow the content down?
Finally, when the window width gets even smaller, the header moves down as well:
This behavior is fine but I'd like the remaining content in the top to take advantage of the extra space and center horizontally. Any idea how? I've had a look at questions such as How do you easily horizontally center a <div> using CSS?, but they all seem to entail increasing the width of the element that I want centered, which breaks the behavior in screenshot #1.
An example of that is seen here:
How do I fix screenshots #2 and #3, without affecting #1?
I have of course also made a fiddle, but I thought screenshots would make the point better:
http://jsfiddle.net/eEPmw/
in it is:
<!DOCTYPE html>
<html>
<head>
<style>
.incbut,.decbut,.rollButton{
background-color:#FF961F;
}
.regular-checkbox{
border-color:#FF961F;
}
body {
background-color:#FCB41B;
color:#753B08;
}
.modifiers{
text-align:left;
min-width:8em;
}
.center{
margin-left:auto;
margin-right:auto;
}
.inputField {
max-width:2em;
border:1px #bababa solid;
vertical-align:middle;
text-align:center;
}
.incbut,.decbut {
border: 1px transparent solid;
display: inline-block;
text-align: center;
vertical-align: middle;
cursor: pointer;
padding: 4px 10px;
position: relative;
width: 2.5em;
}
.rollButton{
border: 1px transparent solid;
display: inline-block;
text-align: center;
vertical-align: middle;
cursor: pointer;
padding: 4px 10px;
position: relative;#FF0000
}
button:active{
background-color:#FF0000;
}
.fieldCol{
float:left;
text-align:center;
max-width=45%;
height:9em;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.incbut,.inputField, .decbut{
min-height:2em;
margin-right:0.5em;
margin-bottom:0.3em;
}
h2{
margin:0.1em;
font-weight:500;
}
h2,button, input{
font-family:inherit;
}
.outputField{
padding:2px;
margin:3px;
border:1px #753B08 solid;
width=2em;
line-height:1.7em;
white-space:nowrap;
}
label {
display: inline;
}
.checkBoxLabel{
margin-left:5px;
font-size:90%;
}
.regular-checkbox {
display: none;
}
.regular-checkbox + label {
border: 3px solid #FF961F;
padding: 9px;
background-color: #FFFFFF;
display: inline-block;
position: relative;
vertical-align:middle;
margin: .1em;
}
.regular-checkbox:checked + label {
border: 3px solid #FF961F;
}
.regular-checkbox:checked + label:after {
content: '\2716';
font-size: 1em;
position: absolute;
top: 0px;
left: 10%;
color: #753B08;
font-weight: 600;
}
.checkboxbox2{
width:8em;
float:left;
}
.colContainer{
text-alignment:center;
}
div.centre{
text-align: left;
width: 17em;
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body style="text-align:center;font-family: 'Segoe UI', 'Open Sans', Verdana, Arial, Helvetica, sans-serif;" class="center">
<!--
<div class="colContainer">
<div class="centre">
-->
<section id="bal_attacker" class="fieldCol">
<h2>Attacker:</h2>
<label for="bal_BS1">BS:</label> <br>
<button type="button" id="bal_BS1inc" class="incbut"> + </button>
<input type="number" id="bal_BS1" value="1" class="inputField">
<button type="button" id="bal_BS1dec" class="decbut"> - </button> <br>
<label for="bal_S">S:</label> <br>
<button type="button" id="bal_Sinc" class="incbut"> + </button>
<input type="number" id="bal_S" value="1" class="inputField"/>
<button type="button" id="bal_Sdec" class="decbut"> - </button>
</section>
<section id="bal_defender" class="fieldCol" >
<h2>Defender:</h2>
<label for="bal_T">T:</label> <br>
<button type="button" id="bal_Tinc" class="incbut"> + </button>
<input type="number" id="bal_T" value="1" class="inputField">
<button type="button" id="bal_Tdec" class="decbut"> - </button> <br>
</section>
<!--
</div>
</div>
-->
<div>
<section title="bal_Modifiers" class="modifiers">
<h2 style="text-align:center;">Modifiers:</h2><br>
<span class="checkboxbox2">
<input type="checkbox" id="bal_harmConv" class="regular-checkbox" /><label for="bal_harmConv"></label>
<label for="bal_harmConv" class="checkBoxLabel">Harm. Conv.</label>
</span>
<span class="checkboxbox2">
<input type="checkbox" id="bal_rrToHit" class="regular-checkbox" /><label for="bal_rrToHit"></label>
<label for="bal_rrToHit" class="checkBoxLabel">R.r. to hit</label>
</span>
<span class="checkboxbox2">
<input type="checkbox" id="bal_rrToW" class="regular-checkbox" /><label for="bal_rrToW"></label>
<label for="bal_rrToW" class="checkBoxLabel">R.r. to wound</label>
</span>
<div style="clear: both;"></div>
</section>
<div style="clear: both;"></div>
</body>
</html>
I apologize that this is not quite a minimal working example - I have been trying for some time now to reduce it further, but I seem to break stuff when I try.
Easy fix:
Put everything in a holder div ("wrap", some call it):
<div id="holder">
<section> .... </section>
<section> .... </section>
<section> .... </section>
</div>
Then make the holder text-align:center; and the sections display:inline-block;, and likely you'll want vertical-align:top;.
#holder{
text-align:center;
}
section{
display:inline-block;
vertical-align:top;
}
From your jsFidle, you'll also want to remove float:left; from .fieldCol
Here's your jsFiddle updated
If you want to create this layout with the responsiveness you've specified, Flexbox is what you're looking for. I've simplified the markup a bit:
http://codepen.io/cimmanon/pen/djwsz
<div id="calculator">
<section id="bal_attacker" class="fieldCol">
<h2>Attacker:</h2>
<div>
<label for="bal_BS1">BS:</label> <br>
<button type="button" id="bal_BS1inc" class="incbut"> + </button>
<input type="number" id="bal_BS1" value="1" class="inputField">
<button type="button" id="bal_BS1dec" class="decbut"> - </button>
</div>
<div>
<label for="bal_S">S:</label> <br>
<button type="button" id="bal_Sinc" class="incbut"> + </button>
<input type="number" id="bal_S" value="1" class="inputField"/>
<button type="button" id="bal_Sdec" class="decbut"> - </button>
</div>
</section>
<section id="bal_defender" class="fieldCol" >
<h2>Defender:</h2>
<div>
<label for="bal_T">T:</label> <br>
<button type="button" id="bal_Tinc" class="incbut"> + </button>
<input type="number" id="bal_T" value="1" class="inputField">
<button type="button" id="bal_Tdec" class="decbut"> - </button>
</div>
</section>
<section title="bal_Modifiers" class="modifiers">
<h2>Modifiers:</h2>
<ul>
<li><label><input type="checkbox" id="bal_harmConv" class="regular-checkbox" /> Harm. Conv.</label></li>
<li><label><input type="checkbox" id="bal_rrToHit" class="regular-checkbox" /> R.r. to hit</label></li>
<li><label><input type="checkbox" id="bal_rrToW" class="regular-checkbox" /> R.r. to wound</label></li>
</ul>
</section>
</div>
These should be all of the styles you need, I've chopped out all of the purely aesthetic styles that aren't really relevant to the layout (colors, padding, etc.):
#calculator, section.modifiers ul {
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
#supports (flex-wrap: wrap) {
#calculator, section.modifiers ul {
display: flex;
}
}
#calculator section {
-webkit-flex: 1 1 30%;
-ms-flex: 1 1 30%;
flex: 1 1 30%;
}
section.modifiers ul {
padding: 0;
}
section.modifiers li {
list-style-type: none;
-webkit-flex: 1 0 33%;
-ms-flex: 1 0 33%;
flex: 1 0 33%;
white-space: pre;
}
Now the bad news is that support for Flexbox is rather poor at the moment. Right now, only Opera, Chrome, and IE10 are capable of rendering this layout.
http://caniuse.com/#feat=flexbox
I would put the headers in parent divs along with the elements you want them to stay with.
<div class="parent">
<h1>Header</h1>
<div class="content">
//Whatever your content is
</div>
</div>
As for centering, margin: 0 auto; is what's typically done for this, but since you're going to have a float, you're probably going to have to write some script to handle that for you based on .length() of the parent divs and the width of the grandparent container.
Here is a quick mock can use to get started.
you need to make a 3 column layout, col1 = attacker, col2 = defender,
col3= modifiers. That will insure that when the screen shrinks past a
point all elements in that column will drop. Next you need to use
percentages within your columns to allow for even distribution of the
elements within, or give each col a fixed with and all the widths of
the elements inside relevant to the with of the parent column.
demo: http://jsfiddle.net/bRRqW/
HTML
<div class="wrapper">
<div class="col">
<h4>Attacker:</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae dignissimos voluptatem in ut minima doloremque fuga qui saepe! Esse laudantium non voluptates deleniti soluta ab praesentium velit id omnis corrupti.</p>
</div>
<div c**strong text**lass="col">
<h4>Defender:</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae dignissimos voluptatem in ut minima doloremque fuga qui saepe! Esse laudantium non voluptates deleniti soluta ab praesentium velit id omnis corrupti.</p>
</div>
<div class="col">
<h4>Modifier:</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae dignissimos voluptatem in ut minima doloremque fuga qui saepe! Esse laudantium non voluptates deleniti soluta ab praesentium velit id omnis corrupti.</p>
</div>
</div>
CSS
.wrapper {
max-width: 600px;
margin: 0 auto;
}
.col {
width: 33.333333%;
float: left;
position: relative;
text-align: center;
min-width: 150px;
background: red;
}