Overflow several inline vertical lists horizontally - html

I have an information bar at the bottom of my site. It has several inline-block elements that are displayed horizontally. As you can see in the fiddle, when the information in the inline-block elements gets too large vertically, it overflows below the bottom edge of the information bar. I would like this stuff to overflow to the right, similar to a newspaper column.
jsfiddle: link
<div class="information-bar">
<div class="information">
<div class="title">Section Title</div>
information <br />
information2 <br />
information3 <br />
information4 <br />
information5 <br />
</div>
<div class="information">
<div class="title">Section Title</div>
information <br />
information2 <br />
information3 <br />
information4 <br />
information5 <br />
</div>
</div>
The goal is to transform this:
to this:
I have tried the css3 columns method: jsfiddle.
Unfortunately it is only designed to work with one column, I believe, because this happens:

I think I got it. There's one issue, however: when the windows is too small, the second information set is displayed below. But I think this isn't a big issue, since it's not that wide.
.information-bar {
width:100%;
height: 100px;
background: #999;
position: absolute;
bottom: 0;
}
.information-bar .information {
display: block;
height: 95px;
-webkit-column-width:144px;
-webkit-column-gap:16px;
-moz-column-width:144px;
-moz-column-gap:16px;
column-width:144px;
column-gap:16px;
-moz-column-count:2;
-webkit-column-count:2;
column-count:2;
}
div.information
{
float:left;
width: 304px; /*quick math: 144*2+16=304*/
}

Using the insight from this gist, we can organize the information in columns, but we must know the maximum column width beforehand:
.information-bar {
width:100%;
height: 100px;
background: #999;
position: absolute;
bottom: 0;
}
.information-bar .information {
display: inline-block;
vertical-align: top;
height: 95px;
}
p.info-element {
line-height: 1.2em;
}
p.info-element:nth-child(n+1):nth-child(-n+5) {
margin-left: 0em;
}
p.info-element:nth-child(6) {
margin-top: -6em;
}
p.info-element:nth-child(n+6):nth-child(-n+10) {
margin-left: 100px;
}
The nth-child(n+1):nth-child(-n+5) selector allows us to select a range of elements (as discussed in the gist). An interesting css hack!
jsfiddle

Related

html/css formatting for middle image and four divs on outside

I am having trouble and need assistance. Essentially, I want a center image div and four divs around the center image with text. Also, when I collapse the page width, I want them to all float centered below one another. Imagine a smartphone image in the middle of the screen and four text blocks (two top and two bottom). Additionally (to complicate things, ha) I want the left top and bottom text blocks to have right aligned text and the right top and bottom text blocks to have left aligned text. When the page collapses, I want all text to be centered. Thank you very much for any assistance!
The problem I have with my existing code: I cannot move the text blocks exactly where I want. I don't want them specifically at the top and bottom. Also, I am having trouble with aligning the text properly.
This is what I have so far:
#solutions2Header {
text-align: center;
padding-top: 50px;
padding-bottom: 50px;
font-size: 40px;
font-weight: lighter;
letter-spacing: 2px;
}
.solutionSection2:after { /*clear float*/
content: "";
display: table;
clear: both;
margin: 0 auto;
}
.solutionSection2 > div {
float: left;
width: 33%;
box-sizing: border-box;
text-align: center;
background-color: red;
}
#media (max-width: 850px) { /*breakpoint*/
.solutionSection2 > div {
float: none;
margin-left: auto;
margin-right: auto;
width: 100%;
background-color: #FAFAFA;
text-align: center;
}
}
.solutions2 {
background-color: green;
height: 100%;
padding-bottom: 500px;
}
#iphonexCenter {
position: relative;
margin: 0 auto;
}
#bottomBox {
padding-bottom: 100px;
}
<div class="solutions2">
<h2 id="solutions2Header">Highlighted Features</h2>
<div class="solutionSection2">
<div>
<p>Charges stored in one <br>place.</p>
<p><br>Provides peace of mind by<br>syncing and storing your charges<br>automatically.</p>
</div>
<div>
<img src="http://via.placeholder.com/300x600" id="iphonexCenter" alt="iPhone X Image" height="600" width="300" style="margin: 0 auto">
</div>
<div>
<p>Individual and team<br>messaging.</p>
<p><br>100% HIPAA compliant text<br>messaging at the tip of your fingers.</p>
</div>
</div>
<div class="solutionSection2">
<div id="bottomBox">
<p>Track daily work<br>progress.</p>
<p><br>Intellegently helps locate<br>missing charges and provides a score<br>card to ensure all charges are entered.</p>
</div>
<div>
<p></p>
</div>
<div id="bottomBox">
<p>Care coordination<br>alerts.</p>
<p><br>Be in the know. We can alert <br>your providers via admit/discharge
<br> notifications, stat, routine consults,<br> and more.</p>
</div>
</div>
</div>
If you don't need support for old browser I would go with flex box. It's quite easy. You can find complete guide to it here https://css-tricks.com/snippets/css/a-guide-to-flexbox/

How to position div to right side and middle of parent div

I have problems with divs. I would like the link "Go" to be right aligned and vertically middle of its parent div. I have tried several ways, but no success yet.
And here you can see my HTML and CSS code:
div.row {
position: relative;
border-bottom: 1px dotted #999999;
}
div.list div.name {
float: left;
width: 40%;
}
div.list div.info {
float: left;
width: 60%;
}
div.list div.action {
display: inline-block;
text-align: right;
vertical-align: middle;
}
<div class="list">
<div class="row">
<div class="name">
<span>1</span>
<br />
1
<br />(2015-09-30)
</div>
<div class="info">
<b>Place:</b>
<br />Now 6
<br />Later 32
<div class="action">
Go
</div>
</div>
</div>
</div>
So, if you have better ideas and know how I could solve my problem, I would love to hear.
If possible, I'm looking for a cross-browser solution. No JavaScript/jQuery allowed this time.
For a parent with a dynamic height and cross browser functionality, you will need to use an older CSS2 trick, using display: table-cell inside a display: table div. This explains it in more detail
HTML
<div class = "info-left">
<b>Place:</b>
<br />Now 6
<br />Later 32
</div>
CSS
.info{
display: table;
}
div.info div.action{
display: table-cell;
vertical-align: middle;
}
Here's a fiddle

Align div content

I know there a many of these about but for some reason I keep failing to implement them.
So I need the content in the class .infobox to be in the middle of the div. So I need it aligned vertical and horizontally.
I have put ALL my code below as some of the "fixes" I tried worked but caused the layout to move and so on. So hopefully you guys can get it aligned without causing the layout to break.
Fiddle is at the bottom. On a side note if you have any tips on how to neaten the layout code please do let me know. But the main problem is aligning the content.
HTML:
<div id="con">
<div id="box">
<div id="header"><h1>Test</h1></div>
<div id="left">
<div class="infobox">Test: <br /> <input /> </div>
<div class="infobox">Test: <br /> <input /> </div>
<div class="infobox">Test: <br /> <input /> </div>
<div class="infobox">Test: <br /> <input /> </div>
</div>
<div id="right">
<div class="resultbox">
<ul>
<li>Test <br />Test</li>
</ul>
</div>
<div class="contactbox">
<ul>
<li>Phone Number: <br /> 00000 000000</li>
<li>Email: <br /> test#Test.com</li>
</ul>
</div>
</div>
</div>
</div>
CSS:
div {
outline: 1px solid #000;
}
#box {
width: 580px;
height: 300px;
}
#header {
height: 15%;
background: url(http://us.123rf.com/400wm/400/400/mechanik/mechanik1112/mechanik111200003/11665900-vector-cartoon-semi-truck.jpg) no-repeat;
background-size:80px 40px;
background-position:right top;
}
#left {
width:70%;
height: 85%;
float: left;
}
#right {
width:30%;
height: 85%;
float: right;
}
.infobox {
width: 50%;
height: 50%;
float: left;
text-align: center;
}
.resultbox {
width: 100%;
height: 50%;
}
.contactbox {
width: 100%;
height: 50%;
font-size: 12px;
}
.contactbox ul, .resultbox ul {
margin: 0;
}
.contactbox li, .resultbox li {
list-style: none;
}
DEMO HERE
What I have tried:
Tried to use padding-top and padding-bottom - This seemed to not align it correctly and then I couldn't get the layout to sit correctly.
Also looked into using position: relative and position: absolute but I have never been too good with them and couldn't manage to get the content to sit where I wanted it to.
I took the liberty of manipulating you mark-up a bit and added an extra div to achieve the output.
Fiddle
HTML
<div class="infobox">
<div class="cent">Test:
<br />
<input />
</div>
</div>
CSS
.infobox > .cent {
outline: 1px solid #0F0;
vertical-align: middle;
margin-top:20%;
}
Whats happening here??? : since your content div infobox has the styling, to give a different set of styling to inner content(which is not floating), you have to use a them under a child div for display!
add margin:0 auto; to #box
like so: http://jsfiddle.net/c82DU/2/
You could take a look at this site, it explains a bit about tables.
The layout u are using looks like a table, so why not use tables? easier text aligning
http://www.w3schools.com/html/html_tables.asp

Centering texted div with absolute position

I need few lines of text to be centered horizontaly and verticaly on image, i read a lot in internet but i didn't helped me any of solution.
HTML:
<div id="textContainer">
Preparing for important meeting? <br />
<b>Drink some coffeee!</b> <br />
<img src="http://i.imgur.com/me2octq.jpg" />
</div>
<div id="baner">
<div class="imgBaner"></div>
</div>
CSS:
.imgBaner {
margin: 0 auto;
width: 100%;
height: 460px;
background: url(http://i.imgur.com/5pijCrS.jpg) no-repeat center;
position: relative;
}
#textContainer {
position: absolute;
font-size: 32px;
text-align: center;
z-index: 1;
color: yellow;
}
Also i'm enclosing fiddle: http://jsfiddle.net/vXzKc/
I appreciate every help!
To achieve this, I'm quite confident you would at least have to know the height of your textcontainer. Then you could use a top/margin combination to solve this.
For what I know a table-cell is the only element that allows its content to be vertically aligned. I have no idea why, but this would allow you to make a little cheat by using display: table-cell
Here's my workaround:
HTML:
<div class="imgBaner">
<div id="textContainer">
Preparing for important meeting? <br />
<b>Drink some coffeee!</b> <br />
<img src="http://i.imgur.com/me2octq.jpg" />
</div>
</div>
CSS:
.imgBaner {
margin: 0 auto;
height: 460px;
background: url(http://i.imgur.com/5pijCrS.jpg) no-repeat center;
display: table-cell;
vertical-align: middle;
}
#textContainer {
font-size: 32px;
text-align: center;
color: yellow;
}
http://jsfiddle.net/vXzKc/1/
Note that display: table-cell may not work in old browsers or could cause different behaviour. I have tested it in the newest browers (IE, Firefox and Chrome) and it seemed to work in all of them.

How can I horizontally center a div with unknown length and use min-width?

I’m updating some legacy code on an old website, and the CSS is a nightmare. All I want to do is make the div that holds a username expand a bit when needed, and keep the outer div centered (horizontally) on the page. The myLabel control is populated based on a user’s name (it typically isn’t pre-defined as John Doe).
Currently, between the 800px value on myContainer, and the 350px value on myGridB, longer usernames are wrapping inside of the div. I’d rather display the long names on one line and, when possible, not bump the other controls to the next line.
I’ve tried using min-width on myContainer and myGridB , but that just allows the divs to expand across the whole page. I see this is common behavior for divs in this question.
I also tried some of the methods in this other question, but that pushed my header content to the left, and I need it centered.
I realize this code is a garbled mess, but I appreciate any ideas…
aspx:
<div class="myLogo1">
<div class="myContainer" style="width: 800px">
<div class="myGridC myLogo2 first">
<a onclick="loadMyHomePage(); "><img src="myImageAddress" /></a>
</div>
<div class="myGridB first last">
<div class="myHome myGridB first last">
<asp:Label runat="server" CssClass="myHome" ID="myLabel">
John Doe
</asp:Label>
<span class="myHome">
<asp:HyperLink NavigateUrl="mySettingsPage.aspx" runat="server">
My Settings
</asp:HyperLink>
</span>
<a href="myLogoutPage.aspx") %>">
<img src="myLogout.jpg") %>" alt="Logout" />
</a>
</div>
<div class="myGridB first last">
<div class="myGridA myPaddingA myHome">
<a href="myOtherPage" target="_blank">
<img width="180px" height="72px" src="myOther.jpg" />
</a>
</div>
</div>
</div>
</div>
</div>
css:
.myLogo1
{
background-color: #363636; /* #000000; */
width: 100%;
height: 125px;
}
.myContainer
{
margin-left: auto;
margin-right: auto;
width: 960px;
}
.myGridA, .myGridB, .myGridC {
display: inline;
float: left;
margin-left: 5px;
margin-right: 5px;
}
.myGridA
{
width: 190px;
}
.myGridB
{
width: 350px;
}
.myGridC
{
width: 390px;
}
.myLogo2
{
border: none 0px transparent;
padding-top: 10px;
}
.first
{
margin-left: 0;
}
.last
{
margin-right: 0;
}
.myHome
{
text-align: right;
display: block;
vertical-align: top;
float: right;
position: relative;
font-size: 9pt;
}
.myHome span
{
font-size: 9pt;
float: left;
padding: 3px 5px 0px 0px;
}
.myContainer .myPaddingA
{
padding-left: 44px;
}
If it's ideas, how I usually horizontally center my divs is I set the container to a certain % width. then i use margin: auto; hope that helped.