I would like to wrap a text div around its sibling image div. Not to be confused with the standard way to wrap text around an image, but with two separate divs.
The example is below:
<div style="width:1000px;">
<div>
<img src="some url" />
</div>
<div>
<p>Some very long text here</p>
</div>
</div>
I want to make it look like the text is wrapping around the image.
Is this possible?
Float the div containing the image left or right.
<div style="width:1000px;">
<div style="float:left">
<img src="some url" />
</div>
<div>
<p>Some very long text here</p>
</div>
</div>
jsFiddle example
Here is a similar way to do it:
http://jsfiddle.net/Sux2Z/
<div>
<img src="http://cdn.memegenerator.net/images/80x80/1167066.jpg" />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam cursus. Morbi ut mi. Nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. Sed eleifend nonummy diam. Praesent mauris ante, elementum et, bibendum at, posuere sit amet, nibh. Duis tincidunt lectus quis dui viverra vestibulum. Suspendisse vulputate aliquam dui. Nulla elementum dui ut augue. Aliquam vehicula mi at mauris. Maecenas placerat, nisl at consequat rhoncus, sem nunc gravida justo, quis eleifend arcu velit quis lacus. Morbi magna magna, tincidunt a, mattis non, imperdiet vitae, tellus. Sed odio est, auctor ac, sollicitudin in, consequat vitae, orci. Fusce id felis. Vivamus sollicitudin metus eget eros.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In posuere felis nec tortor. Pellentesque faucibus.
</div>
.div {width:400px;}
img {
margin:0 10px 10px 0;
float:left;
}
Related
How do i position a centered text or logo (picture 2) at the bottom of the viewport similar to a footer? When the dropdownmenue (picture 3) opens the logo or text should move accordingly to the new height.
So the div below point 5 should dynamically change its height or get out of site in case.
I tried several solutions i googled prior but somehow all did not work like i wanted it to be.
If you know the height of the footer, then you could use min-height, absolute positioning and padding-bottom. However I'm going to assume the more difficult case in which you don't know the height.
<style>
* {box-sizing:border-box;}
.wrapper {min-height:100vh;display:flex;flex-direction:column;}
.main {flex:1 0 auto;}
.footer {background-color:yellow;padding:16px;font-weight:bold;flex:0 0 auto;}
</style>
<div class="wrapper">
<div class="main">
<h1>
Main
</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In aliquet, nibh id placerat viverra, justo purus semper dolor, at lacinia eros mauris eu libero. In finibus a urna dapibus tempus. Aenean ipsum urna, tempor at lectus non, blandit feugiat quam. Donec sed ante orci. Integer laoreet est erat, a feugiat leo posuere sed. Mauris sit amet metus finibus, dapibus nunc ut, molestie erat. Nullam rhoncus sagittis lacus id finibus. Etiam sollicitudin nibh dui, a mollis nisl pharetra vitae. Suspendisse nec laoreet ipsum. Fusce sit amet tempor sem. Vestibulum consequat est in nisl aliquam ornare. Aliquam erat volutpat.
</p>
<p>
Sed vulputate nisl ac est eleifend bibendum. Nullam cursus at ex sit amet dignissim. Sed blandit pretium venenatis. Phasellus at ullamcorper nibh. Aenean nec lectus semper, efficitur diam in, luctus nisi. Phasellus in ligula congue, cursus nunc et, luctus mi. Suspendisse a leo luctus, molestie elit sed, venenatis sem. Nullam lobortis ante nec dictum elementum. Praesent aliquam orci quis molestie consectetur. Aliquam ornare a ipsum dapibus pulvinar. Morbi aliquet posuere ligula, vel volutpat dolor pellentesque vel. Vivamus non euismod leo. Duis feugiat velit a est tincidunt pulvinar. Proin blandit malesuada pulvinar. Nunc ut elementum ex, non vehicula tortor.
</p>
</div>
<div class="footer">
Footer
</div>
</div>
Change the height of your browser up and down to see how this works - the principle is a vertical flexbox that's at least the height of the screen, and a footer that's always at the bottom because the main content grows to fill any spare space.
I need to insert 3 boxes next to each other in wordpress theme. I'm using wp-bootstrap theme.
What I did I create a page and I named it "offers", and I wrote the following code
<div class="col-xs-4 text-center offer-box">
<h1>Offer 1</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. </p>
</div>
<div class="col-xs-4 text-center offer-box">
<h1>Offer 2</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. </p>
</div>
<div class="col-xs-4 text-center offer-box">
<h1>Offer 3</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. </p>
</div>
in css file, I wrote
.offer-box {
background: #f4e759;
height: 300px;
border-radius: 10px;
}
.offer-box h1 {
color: #080808;
}
.offer-box p {
color: #080808;
font-size: 1.2em;
}
It works but the boxes appear without margins. I need to make it with margins left and right for each box.
It should appear like that image exactly
First you should wrap your columns into a row. <div class="row"></div> You should insert another <div> in yor columns for styling purposes because
Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .rows.
Try this
<div class="row">
<div class="col-xs-4">
<div class="text-center offer-box">
<h1>Offer 1</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien
ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi.
Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac
dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus,
tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,
tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
</div>
</div>
<div class="col-xs-4">
<div class="text-center offer-box">
<h1>Offer 2</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien
ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi.
Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac
dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus,
tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,
tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
</div>
</div>
<div class="col-xs-4">
<div class="text-center offer-box">
<h1>Offer 3</h1>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum
tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien
ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi.
Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac
dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus,
tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,
tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
</div>
</div>
</div>
Check this link too for more examples Bootstrap grid system
You need to set the appropriate variables in your style.less file. I believe the ones you need to look at are
#fluidGridColumnWidth
and
#fluidGridGutterWidth
You didn't follow Bootstrap grid syntax. Your .col-* elements should be inside a .row, which in turn should be in a .container. Apply correct nesting and you'll be fine.
Please check following:
Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding.
Use rows to create horizontal groups of columns.
Content should be placed within columns, and only columns may be immediate children of rows.
Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .rows.
read
I have 2 columns (left and right), and these columns are vertical and have images and text and links.
I want to put text in the middle of the page, left column and right column but in the middle there is no column but when i paste the text i get aligning problem. but my text is touching the left column image or boarder, unless if i center the text witch i don't want to center it.
How can i make a space between the element on the left column and my text in the middle of the page so i can justify it properly?
<div style="position: relative; float: right; text-align: center;">
<!-- Images in a vertical line here-->
</div>
<div style="position: relative; float: left; padding-right: 1px; text-align: center;">
<!-- Images in a vertical line here-->
</div>
Thank you,
I believe you're looking to add margin: *some distance in em, px, or %* or padding: *some distance in em, px, or %* to your style rules, depending on where you want that space to occur relative to the CSS box.
Using margin would not help much, but You could put some container (another div) in those divs having padding-right and padding-left.
I made a fiddle to try and make what you've requested: http://jsfiddle.net/MEA8W/
CSS:
.column {
float: left;
text-align: justify;
width: 50%;
}
.column p {
padding: 10px
}
HTML:
<div class="column">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nec vestibulum mi, eu mollis nibh. Vestibulum euismod, orci ut porttitor dictum, velit dolor sodales leo, at iaculis metus leo malesuada mi. In non fermentum nulla. Vivamus in dapibus dui. Nulla quis mi commodo, tincidunt eros gravida, rutrum nibh. Vestibulum ac arcu vulputate, tincidunt ante id, molestie massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
</p>
</div>
<div class="column">
<p>
Quisque aliquam ultricies varius. Phasellus viverra congue massa, et fringilla sapien. Quisque quis tristique nisi, sit amet rhoncus nulla. Nulla bibendum mauris pretium dui faucibus rhoncus. Praesent nec mauris ac enim auctor rhoncus a ultrices nisl. Nulla commodo lorem vel eleifend semper. Etiam ac sapien iaculis lacus interdum sodales. Maecenas sed turpis sapien. Vestibulum faucibus ipsum vitae hendrerit egestas. Phasellus cursus congue tempus. Nulla facilisi. Donec vestibulum posuere est, ut fringilla nunc congue sit amet. Aenean et ultricies quam.
</p>
</div>
I'm trying to create a responsive layout in bootstrap that has a full-height sidebar. I got the responsive part working, but the only problem is - the spacing of the spans don't seem to be playing well together.
On the right side - the main content - it doesn't span to fit the rest of the screen. Also, when the browser gets too small - the main content actually gets partially hidden by the sidebar.
Am I doing something wrong with the spans? If I remove the position: absolute; from the .sidebar, then the whole .content. piece slides underneath the sidebar - but the sidebar is no longer full height, and the content still doesn't fill the rest of the screen evenly. It seems as it's impossible to get this working correctly, but I want to use bootstrap for the convenience of not having to redo all the CSS/JS that's integrated.
Example:
CSS
html {
height: 100%;
}
.sidebar {
background: #333;
margin: 0;
padding: 3em 2em;
height: 100%;
-moz-box-shadow: 0 0 5px #888;
-webkit-box-shadow: 0 0 5px#888;
box-shadow: 0 0 5px #888;
min-height: 100%;
position: absolute;
}
.sidebar .logo { margin-bottom: 3em; }
.content {
margin: 5em;
}
HTML
<body>
<div class="row">
<!-- Navigation for small screens -->
<div class="navbar navbar-inverse hidden-desktop">
<div class="navbar-inner">
<a class="brand" href="/">Home Link</a>
<ul class="nav">
<li>Projects</li>
<li>Photography</li>
<li>Contact</li>
</ul>
</div>
</div>
<!-- Navigation for larger screens -->
<div class="span3 hidden-phone hidden-tablet">
<div class="span3 sidebar">
<div class="logo"><a class="logo-title" href="/">Home Link</a></div>
<ul class="nav nav-pills nav-stacked">
<li>Projects</li>
<li>Photography</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="span9 content">
<div class="span5">
<div class="page-header">
<h1>Hello. <small>This is.</small></h1>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris faucibus est vitae ante lobortis ultricies. Pellentesque blandit massa a velit convallis at accumsan elit gravida. Nulla facilisi. Fusce egestas consectetur velit vitae egestas. Cras vitae justo a sapien gravida condimentum. Donec lacinia lacinia ante. Proin eget est neque, ut egestas nibh. Donec non enim eu sem varius adipiscing. Proin dapibus enim a enim condimentum hendrerit. Donec vestibulum, mauris eget lobortis sagittis, enim libero dapibus augue, ac luctus ipsum augue quis purus. Aenean magna ante, elementum ac ultricies vitae, lobortis vitae augue. Nam metus erat, adipiscing posuere fringilla sit amet, molestie vel dolor. Quisque libero lacus, auctor eget porta vitae, vehicula eget mi. Vestibulum pulvinar hendrerit faucibus.
Aliquam scelerisque nisl sit amet mauris euismod bibendum. Phasellus ac laoreet enim. Praesent a felis id nisl ultrices dignissim. Nam dictum leo at quam vulputate mollis. Curabitur vitae ipsum enim, sit amet sollicitudin neque. Nunc iaculis ultricies convallis. Etiam nunc neque, consequat ac vehicula id, imperdiet in neque. Duis vitae sem magna. Nulla vehicula sapien sit amet sapien tempus tempus. Fusce pharetra dui nec risus sollicitudin vel pharetra arcu lacinia. Quisque eleifend sapien eu quam rutrum sed imperdiet nisi sagittis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque id placerat purus.</p>
</div>
<div class="span3">
<div class="page-header">
<h1>Second Header. <small>Not working.</small></h1>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris faucibus est vitae ante lobortis ultricies. Pellentesque blandit massa a velit convallis at accumsan elit gravida. Nulla facilisi. Fusce egestas consectetur velit vitae egestas. Cras vitae justo a sapien gravida condimentum. Donec lacinia lacinia ante. Proin eget est neque, ut egestas nibh. Donec non enim eu sem varius adipiscing. Proin dapibus enim a enim condimentum hendrerit. Donec vestibulum, mauris eget lobortis sagittis, enim libero dapibus augue, ac luctus ipsum augue quis purus. Aenean magna ante, elementum ac ultricies vitae, lobortis vitae augue. Nam metus erat, adipiscing posuere fringilla sit amet, molestie vel dolor. Quisque libero lacus, auctor eget porta vitae, vehicula eget mi. Vestibulum pulvinar hendrerit faucibus.
Aliquam scelerisque nisl sit amet mauris euismod bibendum. Phasellus ac laoreet enim. Praesent a felis id nisl ultrices dignissim. Nam dictum leo at quam vulputate mollis. Curabitur vitae ipsum enim, sit amet sollicitudin neque. Nunc iaculis ultricies convallis. Etiam nunc neque, consequat ac vehicula id, imperdiet in neque. Duis vitae sem magna. Nulla vehicula sapien sit amet sapien tempus tempus. Fusce pharetra dui nec risus sollicitudin vel pharetra arcu lacinia. Quisque eleifend sapien eu quam rutrum sed imperdiet nisi sagittis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque id placerat purus.</p>
</div>
</div>
</div>
</body>
You're already setting that sidebar to absolute, why bother with the height: 100%? It'd be easier to simply add top:0; bottom:0.
The reason your sidebar is getting slid over the content like that is the absolute positioning of the sidebar. If you want to keep that from happening, I'd recommend setting a defined width in your sidebar class (say, of 240px), then changing content's CSS to read like so:
.content {
padding: 5em;
left: 240px;
right: 0;
top: 0;
bottom: 0;
overflow-y: auto;
}
That should constrain your content appropriately to not slide under your sidebar in any circumstance. Then, in order to make it appropriately responsive, adjust font size and width of your sidebar down as the screen reduces, and decrease the left property of .content to match the width of the sidebar.
Is that what you're looking for?
I'm using the 1140 grid system and have a basic question: Do you need to use empty divs as "spacers" if you want an element to be less than 12 cols wide?
Here's the mockup I'm looking to achieve:
Basically, I want to footer to be only underneath the primary area, but in its own row. The only way I can see to do this is to use a div as a "spacer" to indent the footer to where I want it. Is this how its done?
Here's the code (you'll need to make the preview screen large to see what's going on): http://jsfiddle.net/saltcod/87DZC/
<link rel="stylesheet" href="https://raw.github.com/robertcedwards/HTML-5-Boilerplate-1140-Grid/master/css/1140.css" type="text/css" media="screen" />
<div id="main">
<h1 class="site-title">Site Title</h1>
<div class="container">
<div class="row">
<div id="sidebar" class="threecol">
<h4> Sidebar - Three cols</h4>
<ul>
<li> Item one</li>
<li> Item two</li>
<li> Item three</li>
<li> Item four</li>
<li> Item five</li>
</div>
<div id="primary" class="ninecol last">
<h3>Nine columns</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vel lectus non nisi pellentesque porta sed vel ante. Aliquam ut elit nulla, ac fermentum diam. Donec convallis dui in felis bibendum mollis. Quisque egestas purus libero, ac vehicula tortor. Sed tristique est sed libero pulvinar nec luctus metus vulputate. Etiam ac tempor nunc. Morbi sit amet neque lacus, ac lacinia nisl. Nullam imperdiet ornare sem, non viverra ipsum hendrerit id. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cras vel leo nisl. Ut bibendum ornare urna eget lacinia.</p>
<p>Aliquam ante lectus, ornare a sollicitudin tincidunt, convallis a magna. Sed fermentum lacus id nisl vestibulum interdum. Ut mattis justo in mi vulputate porttitor. Proin sagittis, urna quis blandit semper, velit nisi aliquet dui, et placerat leo purus a erat. Donec congue, elit a eleifend facilisis, lectus sapien placerat augue, in feugiat ante purus sodales libero. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean eget lacus sed enim euismod faucibus. Pellentesque facilisis arcu sed leo gravida a ultricies nisi cursus. Quisque venenatis mollis ligula sed semper. Nullam ac sem purus, non tincidunt velit. In hendrerit, odio sit amet tempus pharetra, libero orci suscipit tellus, eu mollis augue dui a nulla. Vivamus dignissim elit sit amet est mollis sed aliquet lorem posuere. Nulla varius purus quis elit pellentesque et auctor nunc gravida. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed nibh erat, aliquet a luctus vel, pulvinar nec neque.</p>
<h2> If I want three blocks inside #primary, that's easy: </h2>
<div class="fourcol bottom">A</div>
<div class="fourcol bottom">B</div>
<div class="fourcol bottom last">C</div>
</div> <!-- [ .row ] -->
<footer class="row twelvecol">
<h3> But if I want three blocks in my footer, I need to 'indent' it with an empty div?</h3>
<div class="threecol empty bottom"> [ empty div ]</div>
<div class="threecol bottom">A</div>
<div class="threecol bottom">B</div>
<div class="threecol bottom last">C</div>
<p> Isn't this a bit like using a spacer gif in a table layout? </p>
</footer>
</div>
</div>
Isn't this a bit like using a spacer gif in a table layout?
Yes essentially the div will create the space you intended it to make. When using CSS grid frameworks, it's common to use empty divs with the appropriate column class in order to space things accordingly. Of course you can come up with alternate solutions involving relative positioning, etc, but why complicate matters. The last bit of code should look something like this.
<footer class="row twelvecol">
<div class="threecol first"></div>
<div class="threecol bottom">A</div>
<div class="threecol bottom">B</div>
<div class="threecol bottom last">C</div>
</footer>