Divide page in two columns and align them in HTML - html

ImageI would like to display the page in two columns below the heading and center align the buttons the way it is.
I do not understand if I have missed any divs here?
I have been trying to do it but its not showing up the way i expected.
<div>
<div class="slds-p-top--x-large slds-text-align--center slds-p-bottom_small" width="100%">
<span>Help us improve Customer Support</span>
</div>
<table>
<tr>
<td width="50%" class="divText slds-p-bottom--medium leftBtn" >Tell us what you think<br/>
<div class="slds-text-align--center slds-p-top--small slds-p-bottom--large slds-p-top--medium">
<button class="slds-button slds-button--neutral">
<span class="btn-feedback">Provide feedback</span>
</button>
</div>
</td>
<td width="50%" class="vertical-liness divText slds-p-bottom--medium rightBtn" >Collaborate with our team<br/>
<div class="slds-text-align--center slds-p-top--small slds-p-bottom--large slds-p-top--medium">
<button class="slds-button slds-button--neutral">
<span class="btn-feedback">Get Involved</span>
</button>
</div>
</td>
</tr>
</table>
</div>
.THIS .vertical-liness
{
border-left: 2px solid red;
}
.THIS .leftBtn{
padding-left:115px;
float:right;
}
.THIS .rightBtn{
padding-left:175px;
}
.THIS {
background-color: #f4f7f7; /* ibm-cool-white-3; */
border-top: 1px solid #d0dada; /* ibm-gray-10 */
font-size: 20px;
font-weight: normal;
color: #272727; /* ibm-gray-90 */
}
.THIS .divText{
font-size: 16px;
color: #272727; /* ibm-gray-90 */
}

I simplified your markup to show an example. You can create a couple of flex parents and use their centering properties to recreate this.
.flex {
display: flex;
justify-content: center;
align-items: center;
}
.col {
flex-direction: column;
}
.button {
padding: 0 3em;
text-align: center;
}
.button1 {
border-right: 1px solid #ccc;
}
header {
margin: 0 0 .5em;
}
<div class="flex col">
<header>
Help us improve Customer Support
</header>
<div class="buttons flex">
<div class="button button1">
<div>
Tell us what you think
</div>
<button>Provide feedback</button>
</div>
<div class="button button2">
<div>
Tell us what you think
</div>
<button>Provide feedback</button>
</div>
</div>
</div>

You need to create two divs in your body and place the content inside each of them.
body {
width: 500px;
height: 500px;
}
.left, .right {
float: left;
width: 50%;
height: 100%;
}
.left {
background-color: red;
}
.right {
background-color: blue;
}
<div class="left">
<p>Left column</p>
</div>
<div class="right">
<p>Right column</p>
</div>
https://codepen.io/anon/pen/QgLKzQ

float: left; with width: 50%; is the key here.
Be careful that you need either content inside your div like the below example, either give them an height (eg. CSS: .left-float { height: 500px; }
Be careful either that floating elements will break the flow.
You will need to clear float with the next elements:
https://css-tricks.com/almanac/properties/c/clear/
CSS :
.left-float {
width:50%;
float:left;
}
HTML :
<div>
<div class="left-float" style="background-color:green;">
left div
</div>
<div class="left-float" style="background-color:red;">
right div
</div>
</div>
So, with your code... Ugh, put me off this <table> element please !
They are designed to display tabular data and not to provide a way of positioning elements. In your case you do not display tabular data.
An example of how it could be :
https://jsfiddle.net/12fd30bf/
HTML:
<div>
<div class="slds-p-top--x-large slds-text-align--center slds-p-bottom_small" width="100%">
<span>Help us improve Customer Support</span>
</div>
<div class="left-float">
Tell us what you think<br/>
<div class="slds-text-align--center slds-p-top--small slds-p-bottom--large slds-p-top--medium">
<button class="slds-button slds-button--neutral">
<span class="btn-feedback">Provide feedback</span>
</button>
</div>
</div>
<div class="left-float">
Collaborate with our team<br/>
<div class="slds-text-align--center slds-p-top--small slds-p-bottom--large slds-p-top--medium">
<button class="slds-button slds-button--neutral">
<span class="btn-feedback">Get Involved</span>
</button>
</div>
</div>
</div>
CSS :
.left-float {
width:50%;
float:left;
}

Related

How to leave minor div after major div on the same line?

I am scaling several divs and have one that is larger than the others in width and height, the other divs that are after this one are too low, not aligned on the same line.
Note: execute the code below on full page, Follows the code:
body {
background-color: #2E5173;
}
div {
border-radius: 10px;
background-color: white;
margin: 10px;
width: 240px;
height: 250px;
display: inline-block;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)!important;
}
.big {
width: 508px;
height: 508px;
}
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class=""> </div>
<div class="big"> </div>
<div class="">this div is very low</div>
<div class="">this div is very low</div>
The code above looks like this:
I need it to look like this:
Can anyone help?
You can easily do this using CSS grid:
.container {
display:grid;
grid-template-columns:repeat(auto-fit,240px); /* The width */
grid-auto-rows:250px; /* The height */
grid-auto-flow:dense; /*This is the important property*/
/* The margin */
grid-gap:20px;
padding:10px;
}
.container div {
border-radius: 10px;
background-color: #2E5173;
}
.big {
grid-column:span 2; /* Take twice the width*/
grid-row:span 2; /* Take twice the height*/
}
<div class="container">
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div class="big"> </div>
<div>this div is very low</div>
<div>this div is very low</div>
</div>
CSS Grid can provide you with great control of your layouts and is not super complicated. A few of the resources I've used in the last are listed below:
www.w3schools.com/css/css_grid.asp
learncssgrid.com
css-tricks.com/snippets/css/complete-guide-grid
CSS Grid also works well with media queries if you need the page to be responsive.

Applying inline-block to divs, but still having weird

I am trying to align two divs beside each other using the inline-block technique. My code is fairly simple, but I am not sure why is it not working, I don't know what the issue might be.
Here's my code:
.content .sidebar, .content .section {
display: inline-block;
border: none;
min-height: 200px;
width: 250px
}
.sidebar {
background: blue;
}
.section {
background: red;
}
<div>
<div class="header-area">
<h3 id="genericpartTitle">Our album</h3>
</div>
<div class="content">
<div class="sidebar"> hello! </div>
<div class="section">
<h5 class="item-title">Welcome to my section</h5>
<p style="white-space: pre" class="description"> Hello, anything will go here </p>
</div>
</div>
</div>
Aren't they supposed to be aligned beside each other? what's going wrong here? any help would be great.
You just need to add vertical-align: top; for both sidebar and section classes. checkout the code below.
.content .sidebar, .content .section{
display: inline-block;
border: none;
min-height: 200px;
width: 250px
}
.sidebar{
background: blue;
vertical-align: top;
}
.section{
background: red;
vertical-align: top;
}
<div>
<div class="header-area">
<h3 id="genericpartTitle">Our album</h3>
</div>
<div class="content">
<div class="sidebar">
hello!
</div>
<div class="section">
<h5 class="item-title">Welcome to my section</h5>
<p style="white-space: pre" class="description">
Hello, anything will go here
</p>
</div>
</div>
</div>

Align Img Vertically within Div HTML and CSS

I have found the following solution for aligning an img vertically within a div
https://stackoverflow.com/a/7310398/626442
and this works great for a basic example. However, I have had to extend this and I want a row with two bootstrap col-md-6 columns in it. In the first column I want a 256px image, in the second I want a h1, p and a button. I have to following HTML:
<div class="home-costing container">
<div class="row">
<div class="frame">
<span class="helper"></span>
<div class="col-md-6">
<img src="http://www.nijmegenindialoog.nl/wp-content/uploads/in.ico" height="256" width="256" />
</div>
<div class="col-md-6">
<h2>Header</h2>
<p>
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<br /><br/>
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
</p>
<a class="btn btn-default"
href='#Url.Action("Index", "Products")'
role="button">
Learn More
</a>
</div>
</div>
</div>
</div>
and the following CSS:
.home-costing {
color: #fff;
text-align: center;
padding: 50px 0;
border-bottom: 1px solid #ff6500;
}
.home-costing h2 {
text-transform: uppercase;
font-size: 60px;
}
.home-costing p {
font-size: 18px;
}
.home-costing .frame {
height: 256px;
width: 256px;
border: 0;
white-space: nowrap;
text-align: center;
margin: 1em 0;
}
.home-costing .helper {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.home-costing img {
vertical-align: middle;
max-height: 256px;
max-width: 256px;
}
The problem is that now the second column is no longer contained and the text does not wrap and goes off to the right.
How can I center align my image in the first column with the text in the right column and still get the correct wrapping in the second column?
Fiddler: https://jsfiddle.net/Camuvingian/1sc40rm2/2/
Your HTML needed updated, in Bootstrap, the div order should ALWAYS go .container > .row > .col- * - *, your code however went .container > .row > .frame > .col- * - *. I have corrected your HTML and now your code works.
HTML:
<div class="home-costing container">
<div class="row">
<div class="col-md-6">
<img src="http://www.nijmegenindialoog.nl/wp-content/uploads/in.ico" height="256" width="256" class="center-block" />
</div>
<div class="col-md-6">
<h2>UserCost</h2>
<p>Hello, I'm a paragraph</p>
<a class="btn btn-default"
href='#Url.Action("Index", "Products")'
role="button">
Learn More
</a>
</div>
</div>
</div>
</div>
Link to finished code example:
Codepen - Updated & working code
This fixes the word wrap issue also on the p tag.
CSS:
p {
font-size: 18px;
word-wrap: break-word;
}

How to center two divs side by side?

I am using bootstrap and I have two container inside a bootstrap container. Like this:
<div class="container">
<div id="container-map">
aasdasd
</div>
<div id="container-buttons">
asdasda
</div>
</div>
What I am trying to do is center the two divs, #container-map and #container-buttons side by side, inside the main container.
This is my custom CSS for the two divs:
#container-map,
#container-buttons {
display: inline-block;
margin: 0 auto 0 auto;
width: 500px;
height: 500px;
}
Is there a reason you don't want to use the bootstraps built in gridsystem? Something like this?
<div class="container">
<div class="row">
<div class="col-md-3 col-md-offset-3">
<div class="container-map">
asdf
</div>
</div>
<div class="col-md-3">
<div class="container-buttons">
asdf
</div>
</div>
</div>
</div>
Just change your CSS to this
#container-map,
#container-buttons {
float: left;
margin-left: auto;
}
Both containers will be centered and side by side
You can try the code from this example (using text-align: center; on .container display:inline-block; for divs).
<style>
.container {
position:relative;
text-align:center;
}
#dv1, #dv2 {
display:inline-block;
width:100px;
margin:0 3px;
background:#33f;
}
</style>
<div class="container">
<div id="dv1">Div 1</div>
<div id="dv2">Div 2</div>
</div>
you make both your divs to take equal height using flex. You can refer the link to find out the browsers which support it. Have a look at this:
.container {
display: flex;
width: 400px;
background: #eee;
}
.column {
flex: 1;
background: #fff;
border: 1px solid #ccc;
margin: 1px;
}
<div class="container">
<div class="column">
<p>aasdasd</p>
</div>
<div class="column">
<p>asdasda</p>
<p>asdasda</p>
</div>
</div>

CSS div's containing classes

So my logic of Div ID's and Classes must be WAY off.
Heres whats going on:
As you can see the blocks which say PS don't align center with the slider (Which is inside a container.
Here is my css:
/*Front Page Buttons */
#frontpage-Button-Cont {
height: 350px;
}
.button-cont {
width: 175px;
float: left;
margin-left: 10px;
margin-top: 10px;
height: 250px;
}
.thumbnail {
color: #fff;
font-size: 5em;
background: #1f4e9b;
width: 175px;
height: 135px;
text-align: center;
}
.pheader {
color: #DC143C;
min-width: 175px;
text-align: center;
}
.paragraph {
text-align: center;
}
#Align-content {
margin: 0 auto;
}
And here is the html:
<div id="frontpage-Button-Cont">
<div id="Align-content">
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
<div class="button-cont">
<div class="thumbnail">
PS
</div>
<div class="paragraph">
<div class="pheader">
HEADER
</div>
<p>dadaasdasdadadad
</div>
</div>
</div>
</div>
My theory is that I'm using classes incorrectly?
Thanks.
You can Add this to your CSS
#frontpage-Button-Cont {
width:100%;
}
#Align-content {
display:table;
}
With this your margin:o auto can work
View This Demo http://jsfiddle.net/VGPeW/
You need to make sure that the containing div (in this case frontpage-Button-Cont) is the same width as your slider above it. Then add the property text-align:center to the container. That should fix your issue.