Using Boostrap to center image & Text on Smaller devices - html

New to bootstrap and trying to stack the text below the image on mobile devices of 6" aand less. Working well on 7" and more screen devices.
On bigger screens like tablets and desktops the image and the text are on one row appearing as expected.
But on smaller screens I want the the text to stack below the image and both should be centered; was not getting the desired result cos part of the image and text are cut of when stacked. I want the image and the text to be stacked and no part cut off. That is the problem I want solved.
Here is the code:
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-6 col-lg-6 ">
<img class="aligncenter size-full wp-image-99991388" src="http://francmasones.net/wp-content/uploads/2016/10/sm.png" alt="sm" width="398" height="376" /></div>
<div class="col-xs-12 col-sm-6 col-lg-6">
<p style="text-align: left;"><span style="font-size: 17pt; font-weight: 400;"><strong>Etiam porta urna est, id bibendum nisl hendrerit quis. Fusce vel urna ut neque posuere blandit.!</strong></span></p>
<div class="span6">
<p style="text-align: justify;"><span style="font-size: 15pt;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pulvinar, lacus eu sodales tempor, augue tortor finibus nisi, ut vulputate leo metus eget erat. Suspendisse viverra, urna sed sodales bibendum, lorem urna ullamcorper quam, vel bibendum elit mi feugiat risus. Aliquam aliquet, eros nec porttitor bibendum, justo ex facilisis mauris, vel rhoncus purus eros sed nisl. Nulla faucibus posuere varius. Maecenas sed nisi ullamcorper, bibendum ligula id, ornare quam. Donec fermentum pretium lorem et gravida. Nullam placerat augue sed arcu iaculis vehicula. Pellentesque ultrices, justo eget ultrices vestibulum, ligula risus porta nisl, quis imperdiet ante diam sed dui. Morbi ante lacus, pellentesque ut turpis ut, pulvinar pretium nulla.</span></p>
</div>
</div>
</div>
</div>
You insights and kind responses will be appreciated

I don't understand your question clearly. Any How as per my understanding try this code below the row class.
<div class="center-block"> <div>

Try this:
#media (max-width: 768px) {
.col-xs-12 {
text-align: center
}
}

You can write a Media Query for this according to Bootstrap Grid Media Queries breakpoints. Like:
/* For Mobile Devices (equivalent to col-xs-*) */
#media screen and (max-width: 767px) {
.img-holder img {
margin: 0 auto 15px; /* Centers the image */
}
.text-holder .title {
text-align: center; /* Centers the content */
}
.text-holder .description {
text-align: center; /* Centers the content */
}
}
Have a look at the snippet below:
.text-holder .title {
text-align: left;
}
.text-holder .description {
text-align: justify;
}
/* For Mobile Devices (equivalent to col-xs-*) */
#media screen and (max-width: 767px) {
.img-holder img {
margin: 0 auto 15px;
}
.text-holder .title {
text-align: center;
}
.text-holder .description {
text-align: center;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-6 col-lg-6 img-holder">
<img class="img-responsive aligncenter size-full wp-image-99991388" src="http://francmasones.net/wp-content/uploads/2016/10/sm.png" alt="sm" width="398" height="376" /></div>
<div class="col-xs-12 col-sm-6 col-lg-6 text-holder">
<p class="title"><span style="font-size: 17pt; font-weight: 400;"><strong>Etiam porta urna est, id bibendum nisl hendrerit quis. Fusce vel urna ut neque posuere blandit.!</strong></span></p>
<div class="span6">
<p class="description"><span style="font-size: 15pt;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pulvinar, lacus eu sodales tempor, augue tortor finibus nisi, ut vulputate leo metus eget erat. Suspendisse viverra, urna sed sodales bibendum, lorem urna ullamcorper quam, vel bibendum elit mi feugiat risus. Aliquam aliquet, eros nec porttitor bibendum, justo ex facilisis mauris, vel rhoncus purus eros sed nisl. Nulla faucibus posuere varius. Maecenas sed nisi ullamcorper, bibendum ligula id, ornare quam. Donec fermentum pretium lorem et gravida. Nullam placerat augue sed arcu iaculis vehicula. Pellentesque ultrices, justo eget ultrices vestibulum, ligula risus porta nisl, quis imperdiet ante diam sed dui. Morbi ante lacus, pellentesque ut turpis ut, pulvinar pretium nulla.</span></p>
</div>
</div>
</div>
</div>
Also avoid giving inline styles. It's a bad practice.
Hope this helps!

Related

Bootstrap 4.5, Separate Scrollbars, and Make Div Stick to Bottom

I'm trying to organize some elements across 3 columns using Bootstrap 4.5.
The center column will have a long body.
The right column with have content (2 divs) that should be either stuck to the top / bottom. I'm having exceeding difficulty getting the bottom element to stick. The element auto-expands, and I want it to auto-expand from the bottom.
I'm using Tocify as my ToC in the top of this right column.
The left column has several divs. The top div is a banner, which I would like stuck there. The rest of the divs are less important. Depending on the size of the viewport, this column may overflow, in which case I'd like an independent scrollbar for this left column. There should be 2 separate, independent scroll bars (webpage scroll and left-panel scroll).
Here's a bootstrap loaded fiddle with an example (with a long body to demonstrate the issue): https://jsfiddle.net/x1nhrwtf/5/
<body>
<div class="container-fluid">
<main class="container py-3">
<div class="row">
<aside class="col-md-2">
<div class="row banner sticky-top bg-white p-3">
This will be some banner. Should always stick to the top.
</div>
<div class="scrollable-area hide-this-on-small-devices">
<div class="row bg-white p-3">
This column is <em>not</em> supposed to scroll along with the middle section, <em>unless</em> the elements are overflown (in which case, I want a separate scrollbar).
<hr />
</div>
<div class="row bg-white p-3">
This will have a search bar. Hide this on small devices.
</div>
<div class="row bg-white p-3">
This will have announcements. Hide this on small devices.
</div>
<div class="row bg-white p-3">
This will have BuiltWith. Hide this on small devices.
</div>
</div>
</aside>
<section class="content col-md-6">
Lorem ipsum dolor sit amet...
</section>
<aside class="col-md-4">
<div class="toc sticky-top bg-white p-3">
<h3>ToC Section, sticky</h3>
<hr />
This is positioned correct, pretty much.
Should stay at the top, even on small devices.
This element auto-expands to 60% height.
This is a Tocify style ToC:
<div id="toc" class="pl-1"></div>
</div>
<div class="comments sticky-bottom bg-white p-3">
<h3>Comment section</h3>
<hr />
This should stick to the bottom of the column (and page).
This element auto-expands to 40% height.
</div>
</aside>
</div>
</main>
<footer class="footer">Here is a footer. It should be stuck across the bottom. Why is it not there?</footer>
</div>
</body>
CSS Attempt:
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
.toc {
max-height: 60%;
}
.comments {
max-height: 40%;
}
.scrollable-area {
overflow-y: auto;
}
This is the solution i worked out. There is the container for the three columns, with overflow: hidden and height: 100vh to avoid page scroll. And the three columns with overflow scroll to allow parallel scrolling.
The rest of your requirements are met, i think. The top components of left and right are marked gray and tay on top. The comment stays on bottom of page and column. And the footer is visible.
html,
body {
margin: 0;
padding: 0;
}
.container {
display: flex;
flex-direction: row;
justify-content: space-evenly;
width: 100vw;
height: 100vh;
border: solid 1px red;
overflow: hidden;
}
.col {
display: flex;
flex-direction: column;
justify-content: flex-start;
height: auto;
overflow: auto;
padding: 3px;
}
.col-md-2 {
width: 16.6666666667%;
}
.col-md-4 {
width: 33.3333333334%;
}
.col-md-6 {
width: 50%;
}
.center {
background-color: green;
text-align: justify;
}
.sticky-top {
position: fixed;
width: inherit;
top: 0;
background-color: gray;
}
.sticky-bottom {
position: sticky;
bottom: 0;
}
.scrollable-area {
position: relative;
z-index: -1;
}
.toc {
height: 60%;
max-height: 60%;
}
.comments {
position: fixed;
bottom: 0;
z-index: -1;
height: 40%;
max-height: 40%;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
z-index: 100;
background-color: black;
color: white;
}
<div class="container">
<div class="col left col-md-2">
<div class="banner sticky-top">
This will be some banner. Should always stick to the top.
</div>
<div class="scrollable-area hide-this-on-small-devices">
<div class="row bg-white p-3">
This column is <em>not</em> supposed to scroll along with the middle section, <em>unless</em> the elements are overflown (in which case, I want a separate scrollbar).
<hr />
</div>
<div class="row bg-white p-3">
This will have a search bar. Hide this on small devices.
<hr />
</div>
<div class="row bg-white p-3">
This will have announcements. Hide this on small devices.
<hr />
</div>
<div class="row bg-white p-3">
This will have BuiltWith. Hide this on small devices.
<hr />
</div>
</div>
</div>
<div class="col center col-md-6">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Volutpat sed cras ornare arcu dui vivamus arcu. Iaculis eu non diam phasellus vestibulum lorem sed risus ultricies. Suscipit tellus
mauris a diam maecenas. Egestas maecenas pharetra convallis posuere morbi leo urna molestie. Augue neque gravida in fermentum et sollicitudin ac. Amet purus gravida quis blandit turpis cursus in hac. Aenean pharetra magna ac placerat vestibulum. Quis
ipsum suspendisse ultrices gravida dictum fusce ut placerat orci. Ut placerat orci nulla pellentesque dignissim enim sit amet venenatis. Lacus vestibulum sed arcu non odio euismod.<br> Amet venenatis urna cursus eget nunc scelerisque viverra.
Sodales ut eu sem integer vitae justo eget. Tempor orci eu lobortis elementum. Dictum at tempor commodo ullamcorper a lacus. Vel facilisis volutpat est velit egestas dui id ornare. Urna duis convallis convallis tellus. Blandit massa enim nec dui nunc
mattis enim ut. Quisque non tellus orci ac. Tempus egestas sed sed risus pretium quam vulputate dignissim suspendisse. Fermentum leo vel orci porta. Duis tristique sollicitudin nibh sit amet commodo nulla facilisi. Elementum facilisis leo vel fringilla
est ullamcorper eget. Condimentum lacinia quis vel eros donec ac. Felis eget velit aliquet sagittis id consectetur purus. Fringilla ut morbi tincidunt augue interdum velit euismod. Faucibus a pellentesque sit amet porttitor. Sapien eget mi proin sed
libero enim sed. Nulla porttitor massa id neque aliquam vestibulum morbi blandit cursus.<br> Mattis pellentesque id nibh tortor id aliquet lectus proin nibh. Elit duis tristique sollicitudin nibh sit. Risus commodo viverra maecenas accumsan lacus
vel. Elementum sagittis vitae et leo duis ut diam. Mauris vitae ultricies leo integer malesuada nunc vel. Adipiscing tristique risus nec feugiat in fermentum posuere. Orci sagittis eu volutpat odio. Aliquet bibendum enim facilisis gravida neque convallis
a. Eget lorem dolor sed viverra ipsum nunc. Orci eu lobortis elementum nibh tellus molestie nunc non. Nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Gravida arcu ac tortor dignissim convallis aenean et. Tincidunt tortor aliquam nulla
facilisi cras fermentum odio. Vel pretium lectus quam id leo in vitae turpis. Ullamcorper velit sed ullamcorper morbi tincidunt ornare. Sit amet commodo nulla facilisi nullam. Senectus et netus et malesuada. Id porta nibh venenatis cras sed felis
eget.<br> Ultrices sagittis orci a scelerisque. Faucibus et molestie ac feugiat sed lectus vestibulum mattis ullamcorper. Id velit ut tortor pretium viverra suspendisse potenti nullam. Purus gravida quis blandit turpis cursus. Non curabitur gravida
arcu ac tortor dignissim. Porta nibh venenatis cras sed. Gravida dictum fusce ut placerat orci nulla. Justo laoreet sit amet cursus sit amet dictum. Non diam phasellus vestibulum lorem sed risus. Non enim praesent elementum facilisis leo vel fringilla
est ullamcorper.<br> Mattis aliquam faucibus purus in massa tempor nec feugiat nisl. Porta non pulvinar neque laoreet suspendisse interdum. Leo urna molestie at elementum. Aliquet porttitor lacus luctus accumsan. Arcu non sodales neque sodales ut.
Vitae turpis massa sed elementum tempus egestas. Faucibus in ornare quam viverra orci sagittis. Sociis natoque penatibus et magnis dis parturient. Lacus suspendisse faucibus interdum posuere. Odio facilisis mauris sit amet massa vitae tortor condimentum
lacinia.
</div>
<div class="col right col-md-4">
<div class="toc sticky-top bg-white p-3">
<h3>ToC Section, sticky</h3>
<hr /> This is positioned correct, pretty much. Should stay at the top, even on small devices. This element auto-expands to 60% height.
</div>
<div class="comments sticky-bottom bg-white p-3">
<h3>Comment section</h3>
<hr /> This should stick to the bottom of the column (and page). This element auto-expands to 40% height.
</div>
</div>
</div>
<footer class="footer">Here is a footer. It should be stuck across the bottom. Why is it not there?</footer>
The footer still right there (at the bottom). I think you didn't see it because jsfiddle's console covered it.

Align image left of title and paragraph then between them in small screens

I'm trying to create a block of heading and text + image where:
- In large screens, they will alternate left and right.
- In smaller screens, the image will be below the heading and above the paragraph text.
This is an example of how it should look like
I tried using a flexbox but the heading and text wouldn't play along nicely. I tried inline-block, but the image wouldn't vertical-align in the wrapper.
I'm adding this to a squarespace website and the template doesn't use bootstrap, so I cannot use that.
<div class="alternating-content-block even">
<div class="heading">
<h2>Heading</h2>
</div>
<div class="image">
<img src="https://images.squarespace-cdn.com/content/v1/56099b28e4b0e9a8dd53c467/1474681761217-VA1F29OQYAQX8IIW1018/ke17ZwdGBToddI8pDm48kFNHtaRIWeOk0XtEG2Iz2ptZw-zPPgdn4jUwVcJE1ZvWhcwhEtWJXoshNdA9f1qD7Xj1nVWs2aaTtWBneO2WM-tqmpERyOMWWNh4XLI3lmIESCawszvU15S2rzqX3HdiIw/image-asset.jpeg?format=300w" />
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer venenatis posuere urna et sagittis. In elit elit, venenatis quis leo ut, accumsan lobortis arcu. Donec ut ultricies lorem. Donec id eleifend ipsum. In mi massa, lacinia non facilisis at, vehicula eget purus. Pellentesque dui dolor, scelerisque at ultrices at, fermentum sit amet dui. Mauris posuere gravida ornare. Sed id consectetur lorem. Integer pulvinar mi sed mi dignissim blandit. Vestibulum aliquet ex elit, vitae condimentum nibh faucibus id. Aliquam rhoncus risus non turpis pulvinar, vitae eleifend turpis eleifend. Etiam sed mi eget lorem pharetra imperdiet id ut est. Praesent mollis suscipit velit pharetra posuere. In in accumsan nisl.
</div>
</div>
<div class="alternating-content-block odd">
<div class="heading">
<h2>Heading</h2>
</div>
<div class="image">
<img src="https://images.squarespace-cdn.com/content/v1/56099b28e4b0e9a8dd53c467/1474681761217-VA1F29OQYAQX8IIW1018/ke17ZwdGBToddI8pDm48kFNHtaRIWeOk0XtEG2Iz2ptZw-zPPgdn4jUwVcJE1ZvWhcwhEtWJXoshNdA9f1qD7Xj1nVWs2aaTtWBneO2WM-tqmpERyOMWWNh4XLI3lmIESCawszvU15S2rzqX3HdiIw/image-asset.jpeg?format=300w" />
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer venenatis posuere urna et sagittis. In elit elit, venenatis quis leo ut, accumsan lobortis arcu. Donec ut ultricies lorem. Donec id eleifend ipsum. In mi massa, lacinia non facilisis at, vehicula eget purus. Pellentesque dui dolor, scelerisque at ultrices at, fermentum sit amet dui. Mauris posuere gravida ornare. Sed id consectetur lorem. Integer pulvinar mi sed mi dignissim blandit. Vestibulum aliquet ex elit, vitae condimentum nibh faucibus id. Aliquam rhoncus risus non turpis pulvinar, vitae eleifend turpis eleifend. Etiam sed mi eget lorem pharetra imperdiet id ut est. Praesent mollis suscipit velit pharetra posuere. In in accumsan nisl.
</div>
</div>
.alternating-content-block {
position: relative;
}
.alternating-content-block .text {
display: inline-block;
vertical-align: middle;
width: 66%;
}
.alternating-content-block .heading {
display: inline-block;
vertical-align: middle;
width: 66%;
}
.alternating-content-block .image {
display: inline-block;
vertical-align: middle;
text-align: center;
width: 33%;
}
.alternating-content-block.even .text,
.alternating-content-block.even .heading {
float: left;
}
.alternating-content-block.even .image {
float: right;
}
.alternating-content-block.odd .text,
.alternating-content-block.odd .heading {
float: right;
}
.alternating-content-block.odd .image {
float: left;
}
One possibility would be to use float (left or right, as needed) on the images, place them before the text in the HTML code and have a media query for small screens that changes the image CSS to float: none; display: block;to display it in its own block (by default 100% wide) above the text.

How to construct a responsive grid of DIVs that all have the same width

I'm coding some HTML and CSS that needs to organize a number of blocks of nested DIVs into a responsive grid which keeps each block of nested DIVs' width the same. I've tried just about everything but nothing has worked so far. As it is now, each block of nested DIVs stacks on top of the next one vertically. I'd like the blocks of nested DIVs to be responsive, in that they wrap if the browser window is resized. Also, I need each DIV to be the same width. My code may be ugly and lacking in style but it's what I had to write to get the current layout working.
I've tried using the flex and flex-wrap properties to create a grid, but it has not worked and it only horribly screws up the display of the nested DIV blocks.
<!DOCTYPE html>
<html>
<head>
<style>
.border_box_main {
width: 100%;
height: auto;
border: 15px solid Green;
box-sizing: border-box;
background-color: Aquamarine;
margin: auto;
text-align: center;
}
.list_1 {
width: 30%;
margin-right: 10px;
margin-left: 10px;
margin-top: 10px;
margin-bottom: 10px;
padding: 15px;
background-color: Grey;
display: inline-block;
}
.list_subtext {
text-align: left;
margin-left: 10px;
margin-top: 10px;
margin-bottom: 10px;
padding: 15px;
font-size: 10px;
}
hr {
color: solid black;
width: 75%;
text-align: center;
}
.list_2 {
width: 85%;
margin-right: 10px;
margin-left: 10px;
margin-top: 10px;
margin-bottom: 10px;
padding: 15px;
background-color: White;
display: inline-block;
}
.div_list_1 {
display: list-item;
list-style-type: disc;
list-style-position: outside;
text-align: left;
}
</style>
<title>Test</title>
</head>
<body>
<div class="border_box_main">
<hr><br>
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">
Test 1 2 3 4.
<div class="list_subtext">(Test2)</div>
</div>
</div>
</div>
</div>
</div>
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">
Test 1 2 3 4.
<div class="list_subtext">(Test2)</div>
</div>
</div>
</div>
</div>
</div>
<hr><br>
</div>
</body>
</html>
I get a vertical list of nested DIV blocks, with the same width. The problem is that I want the list of nested DIV blocks to flow horizontally, with each one having the same width and its position on the screen being centered. The list should also be responsive to changes in the browser window size.
EDIT : The JSFiddle link is here https://jsfiddle.net/g42nxk0p/ . AS you might have noticed, when the output window is small, my HTML doesn't render correctly. Specifically, the borders do not shrink in response to the window width. I'd also like to fix this.
Do you try to use Grid layout? I use often grid layout for the main layout and flexbox for items that are in the grid. (CSS Grid Layout Module
- A Complete Guide to Grid)
Well, I finally got it working, at least on Desktop devices :) Thanks to Khoi Le for the suggestions for the grid layout code. I had to tweak his and my code, but I finally got it working. I still have to add the mobile-friendly code, and hopefully that won't break the layout. The only problem, and what seems to be necessary, although it's a kludge, was that I had to add a static pixel width to the DIVs. Here is an example of the working code :
<!DOCTYPE html>
<html>
<head>
<style>
.border_box_main {
width: 100%;
height: auto;
border: 15px solid Green;
box-sizing: border-box;
background-color: Aquamarine;
margin: auto;
text-align: center;
overflow: hidden;
word-wrap: break-word;
}
.list_1 {
width: 320px;
padding: 15px;
display: inline-block;
overflow: hidden;
word-wrap: break-word;
}
.list_subtext {
text-align: left;
margin-left: 10px;
margin-top: 10px;
margin-bottom: 10px;
padding: 15px;
font-size: 10px;
overflow: hidden;
word-wrap: break-word;
}
hr {
color: solid black;
width: 75%;
text-align: center;
}
.list_2 {
margin: 5px;
padding: 15px;
background-color: White;
display: inline-block;
border: 20px solid grey;
width: 200px;
overflow: hidden;
word-wrap: break-word;
}
.div_list_1 {
display: list-item;
list-style-type: disc;
list-style-position: outside;
text-align: left;
overflow: hidden;
word-wrap: break-word;
}
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
justify-content: center;
overflow: hidden;
word-wrap: break-word;
}
.item {
width: 350px;
margin: 20px;
padding: 5px;
min-height: 100px;
text-align: center;
overflow: auto;
word-wrap: normal;
}
</style>
<title>Test...</title>
</head>
<body>
<div class="border_box_main">
<br><br>
<hr>
<br>
<div class="container">
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce pharetra iaculis pretium. Nullam risus dui, placerat et fermentum sed, efficitur non massa. Nulla congue facilisis ipsum at tincidunt. Aenean ut orci efficitur, consequat enim vitae, facilisis ex. Pellentesque imperdiet, arcu eget feugiat ultricies, neque magna hendrerit tortor, ut feugiat risus velit non eros. Aenean scelerisque pulvinar ante, vel porttitor ipsum blandit et. Aliquam eu metus eu felis blandit porta. Quisque ac neque sapien. Duis blandit nisl vitae dui bibendum congue sed sed dolor. Suspendisse vitae arcu placerat, placerat justo non, ornare ex. Phasellus suscipit ultrices ex, sed mollis eros viverra nec. Integer non aliquet augue, vitae condimentum diam. Phasellus ultrices, arcu id malesuada tincidunt, ligula elit tempus felis, quis tincidunt leo nisl sit amet velit. Sed sit amet efficitur turpis, id scelerisque nulla.
<div class="list_subtext">Test1</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">In sit amet odio velit. Cras fermentum est id dapibus accumsan. Pellentesque metus lacus, gravida id justo sit amet, sodales hendrerit neque. Nulla ac orci ac neque placerat commodo. Quisque tortor risus, sagittis vitae risus a, lobortis lobortis eros. Nulla facilisi. Suspendisse luctus leo vel felis cursus, quis aliquet diam aliquet. Maecenas vitae augue placerat, posuere ex ac, venenatis nisi. Nunc mi diam, gravida eu erat nec, porta scelerisque nulla. Proin hendrerit nulla massa, non elementum lectus rhoncus quis. In dapibus vel nunc vel porta. Sed maximus purus vel enim egestas accumsan. Sed sollicitudin libero ac quam iaculis tempus. <div class="list_subtext">Test2</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Morbi at gravida urna. Morbi imperdiet nisl vel felis interdum, a volutpat turpis eleifend. Sed ultrices sollicitudin elit, sit amet tincidunt velit pharetra ut. Integer tincidunt metus at purus vestibulum, ut viverra orci volutpat. Donec hendrerit quam eu mauris molestie, sed congue orci vehicula. In ac justo tincidunt, suscipit ipsum in, mattis mauris. Duis lobortis lectus at nunc faucibus consectetur. <div class="list_subtext">Test3</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Cras sit amet sapien mi. Fusce at convallis metus. Quisque ac imperdiet ex. Morbi dictum, felis sit amet placerat malesuada, lectus arcu interdum ipsum, ac egestas nisi leo eget dui. Maecenas id ex rutrum, condimentum quam et, suscipit justo. Nam et pellentesque arcu, vel porttitor sapien. Integer egestas enim quam, vehicula tristique tellus sodales ut.
<div class="list_subtext">Test4</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Proin sapien urna, cursus eu eros ac, iaculis sollicitudin massa. Vestibulum et sodales felis. Nulla vel cursus lorem. Sed dui libero, cursus sed est in, venenatis volutpat ex. Pellentesque tincidunt risus ut lorem euismod, sit amet facilisis lectus fermentum. Nunc tellus sapien, interdum eu urna id, viverra ultricies massa. Pellentesque elementum nisl leo, ullamcorper elementum metus mattis vel. Cras sodales facilisis eros, a tincidunt nisl vulputate in. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut justo euismod, dictum libero in, finibus arcu. <div class="list_subtext">Test5</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1"> Proin et leo ultricies, elementum odio a, iaculis sem. Nam nec lacus facilisis metus elementum sodales. Aenean convallis luctus nibh, a luctus tortor. Sed dictum lorem et nulla fermentum, ac consequat justo sagittis. Nullam rhoncus ornare massa eget auctor. Praesent at convallis diam. Aliquam viverra mollis neque, ac porta ligula fringilla ac. Praesent neque nisl, cursus vitae sagittis ut, tristique eget justo. In semper urna nec justo egestas vestibulum.
<div class="list_subtext">Test6</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Donec et cursus nisl, sed dictum justo. Cras pretium lorem in dui sollicitudin ullamcorper. Nullam et dolor id velit imperdiet consequat. Aenean turpis ex, convallis bibendum elit vitae, fermentum molestie erat. Donec fringilla pulvinar metus, eu varius metus condimentum vel. Suspendisse potenti. Aliquam rutrum euismod dolor, quis eleifend dui faucibus id. Ut vitae leo vel quam tempor dapibus sit amet at ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer quis pharetra leo, vel rutrum diam. Aliquam dapibus tellus sit amet tellus imperdiet, et tincidunt metus ornare. Sed sit amet urna ex. Praesent accumsan ut odio sit amet aliquet. Nunc non varius diam, sed faucibus dolor. Cras ut nunc et purus iaculis luctus nec et quam.
<div class="list_subtext">Test7</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Maecenas eget tellus mollis, efficitur est a, scelerisque sem. Sed efficitur leo lectus, et fringilla ipsum pellentesque eget. Phasellus vitae egestas magna, sed lobortis erat. Aliquam eget imperdiet ligula, ac dapibus mauris. Sed lobortis bibendum felis, quis varius purus varius sagittis. Vestibulum suscipit dapibus leo non consequat. Phasellus tempor, eros vitae tempor hendrerit, dolor nibh semper metus, a hendrerit turpis leo in est. Donec faucibus iaculis mollis. Suspendisse laoreet a risus a maximus. Ut massa lacus, hendrerit eget eros et, ultrices porttitor libero. Nunc ac laoreet odio. Proin viverra molestie ipsum et faucibus.
<div class="list_subtext">Test8</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div style="text-align: center;">
<div class="list_1">
<div style="text-align: center;">
<div class="list_2">
<div class="div_list_1">Praesent vitae dolor lacus. Aenean gravida, erat sed ornare laoreet, leo dolor viverra tellus, venenatis mollis nibh dolor id nisi. Morbi ac tempus elit. Maecenas maximus felis ac felis laoreet, id congue urna sollicitudin. Nulla rhoncus feugiat magna, a auctor sapien pharetra nec. Nunc egestas ipsum mi, non volutpat mi dictum non. Ut molestie augue a ex malesuada pretium. In vestibulum efficitur mi. Integer aliquet placerat tempor. Nunc ultricies ipsum vel dictum eleifend. Integer ut dapibus enim, nec porttitor magna. Nulla quis sodales lacus.
<div class="list_subtext">Test9</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr><br>
</div>
</body>
</html>
The JSFiddle is here : https://jsfiddle.net/jdbtwo/ch3tfu2q/
Notice how the tops of the DIVs are all aligned. Also, the grid is repsonsive and responds to browser window size changes properly.
jdb2
EDIT : To get my code working on mobile devices, I had to pair every "width: x;" with a "min-width: x;" . Still, in the browsers on my iPhone, the listing is shifted to the left. I don't know what's causing this.

Image in a line of text / Paragraph

I'm trying to insert an image into a paragraph that would look like the ball in this image:
.
I'm using Bootstrap if that matters.
I've been playing around using
<div class="col-md-8 col-xs 8">
<h1><?php echo $config["First"]["Title"];?></h1>
<p><?php echo $config["First"]["Text"];?></p>
<?php echo '<img src="img/ball.png" class="img" style="
float: right;
position: relative;
">';?>
</div>
This what I've been come up yet, but it just goes below the text, doesn't go inline.
This is the CSS for p tag:
p {
color: rgba( 180, 180, 180, 1 );
position: relative;
float: left;
}
Your img should be inside your <p> element:
<p><img src="imgs/ball.png" class="img" />paragrag content goes here</p>
Then just make your image float:left;
As stated before, you need to move the floated image to earlier in the text. Here's a working codepen: http://codepen.io/vic3685/pen/GqLyWX
<section id="first" class="first-section">
<div class="container">
<div class="row">
<div class="col-md-4 col-xs 4">
<img src="http://placekitten.com/200/300" class="img-responsive" style="
width: 100px; float: left;
">
</div>
<div class="col-md-8 col-xs 8">
<h1>Title field here</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tincidunt risus sagittis, molestie sapien vitae, finibus libero. Nunc ac elit pharetra, semper urna in, mollis nulla. Donec eget vehicula libero. Suspendisse porttitor diam at tellus placerat pharetra. Donec suscipit, ligula vitae auctor vulputate, risus erat pretium leo, ut laoreet libero sem in sem. Quisque et massa fermentum, molestie lacus et, auctor risus. Duis pretium lacinia massa, a semper justo gravida quis. Integer non arcu lectus. Ut vulputate et ipsum et molestie. Donec id iaculis justo. Praesent leo lacus, posuere id ligula at, semper volutpat magna. Suspendisse id laoreet erat, tempus commodo neque. Pellentesque dignissim laoreet vestibulum. Vivamus laoreet tristique commodo. Curabitur vestibulum rutrum urna nec lacinia.</p>
<p><img src="http://placekitten.com/200/300" class="img" style="
display: inline-block;
position: relative;
float: right;
width: 150px;
">Praesent a scelerisque augue. Nulla gravida mauris a mauris malesuada, et facilisis justo maximus. Praesent convallis gravida molestie. Morbi dignissim felis a urna egestas tristique. Nulla facilisi. Cras ipsum lorem, interdum non mi et, convallis molestie diam. Vivamus pellentesque fringilla est sit amet tempor. Sed vulputate, eros non aliquet feugiat, lectus urna laoreet arcu, quis malesuada sapien eros ut est. Ut scelerisque faucibus commodo. In finibus accumsan augue quis blandit. Phasellus maximus urna arcu, vitae malesuada risus rutrum a. Nam non augue eget metus varius pretium vitae ut turpis. Integer non elit odio. Nullam nec fermentum ante, sit amet mattis turpis. Maecenas felis lectus, semper sed leo ut, ullamcorper placerat orci.
</p>
<p> Nam iaculis interdum urna, at varius turpis vulputate id. Nulla eu odio eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In et suscipit nisl. Curabitur eu faucibus tortor. Proin eget lorem at lectus fringilla porta quis nec dolor. Curabitur metus arcu, ullamcorper ac gravida nec, tristique suscipit lorem. Donec auctor sodales risus eu fermentum.</p>
</div>
</div>
</div>
</section>
For more in-depth information on floats, see: https://css-tricks.com/all-about-floats/
Here is a working fiddle, the best way to accomplish this is by putting the image at a certain point in the text, say after one or two paragraphs:
https://jsfiddle.net/5p4xdLto/1/
CSS:
.wrapper {
position: relative;
}
.left {
width: 100px;
position: absolute;
}
p {
padding-left: 120px;
}
.right {
float: right;
width: 100px;
}

Why footer goes to sidebar area?

I think this a noob question and already answered but I failed to find the answer.
codepen
I am making a simple 2 column layout. columns are working fine but footer goes to sidebar area if content area is taller than sidebar area.
HTML:
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }
/* GROUPING */
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
}
.group {
zoom:1; /* For IE 6/7 */
}
/* GRID OF THREE */
.span_2_of_3 {
width: 66.1%;
}
.span_1_of_3 {
width: 32.2%;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
#media only screen and (max-width: 480px) {
.col { margin: 1% 0 1% 0%;}
.span_3_of_3, .span_2_of_3, .span_1_of_3 { width: 100%; }
}
<html>
<head>
</head>
<body>
<div class="wrapper"> <div class="container">
<div class="col span_2_of_3">
<div>Sed at ante finibus, porttitor nunc sit amet, interdum tellus. Suspendisse tincidunt lectus a enim tincidunt, quis semper tellus luctus. Mauris ut dui dolor. Donec imperdiet fringilla ornare. Nunc in lectus magna. Curabitur at purus libero. Nunc ultricies scelerisque felis. Proin tristique, odio id pharetra condimentum, metus libero porta lacus, at eleifend justo sapien eu ipsum. Donec vel purus gravida, convallis ligula id, scelerisque urna. In eleifend mattis mauris sit amet pharetra. Praesent eget libero augue. Vestibulum ut justo hendrerit, ornare erat sit amet, tristique augue. Quisque tortor ex, pulvinar sit amet elementum nec, fringilla eu urna. Fusce interdum convallis felis, sit amet posuere nulla ornare a. Quisque quis vulputate lacus. Proin mollis lectus mi, sed egestas nibh mollis in. Sed at ante finibus, porttitor nunc sit amet, interdum tellus. Suspendisse tincidunt lectus a enim tincidunt, quis semper tellus luctus. Mauris ut dui dolor. Donec imperdiet fringilla ornare. Nunc in lectus magna. Curabitur at purus libero. Nunc ultricies scelerisque felis. Proin tristique, odio id pharetra condimentum, metus libero porta lacus, at eleifend justo sapien eu ipsum. Donec vel purus gravida, convallis ligula id, scelerisque urna. In eleifend mattis mauris sit amet pharetra. Praesent eget libero augue. Vestibulum ut justo hendrerit, ornare erat sit amet, tristique augue. Quisque tortor ex, pulvinar sit amet elementum nec, fringilla eu urna. Fusce interdum convallis felis, sit amet posuere nulla ornare a. Quisque quis vulputate lacus. Proin mollis lectus mi, sed egestas nibh mollis in. </div>
</div>
<div class="col span_1_of_3">
Here is widget content
</div></div></div>
<footer>
<div class="container">
This is footer content
</div>
</footer>
</body>
</html>
http://codepen.io/anon/pen/azyEbb
You forgot to close one div, and your footer needs
footer {
clear: both;
}
as well.
Same solution as that from Sirence, just other code:
CSS:
.clearfix:after {
content: ".";
clear: both;
display: block;
visibility: hidden;
height: 0px;
}
HTML:
<html>
<head>
</head>
<body>
<div class="wrapper clearfix">
<div class="container">
<div class="col span_2_of_3">
<div>Sed at a...stas nibh mollis in.</div>
</div>
</div>
<div class="col span_1_of_3">
Here is widget content
</div>
</div>
<footer>
<div class="container">
This is footer content
</div>
</footer>
</html>