I'm having a dilemma which is causing my website to be pretty ugly, what I'm essentially trying to do is make these tiles wrap nicely and show more tiles on one row dependent on the client's screen size.
Most of it works but it looks terrible if aligned to the center (Tiles center)
Text-align: center
Text-align: left
What I want it to look like:
http://puu.sh/d3Rpt/6d1550eaa3.png
As you can see, the left align looks more aesthetically pleasing but there is a massively ugly piece of white space, what I want to do is remove that white space or center the actual tile parent.
<div class='ioholder'>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
<div class="imghold">
<p>
Test
</p>
</div>
</div>
.ioholder
{
display:inline-block;
text-align:left;
padding:10px;
}
.imghold
{
vertical-align:top;
display:inline-block;
min-width:200px;
width:200px;
height:240px;
max-height:240px;
margin:4px;
text-align:left;
background-color:rgb(240,240,240);
border-style:solid;
border-width:1px;
border-color:rgb(175,175,175);
border-radius:2px;
}
This looks like a good use case for flex boxes. You can set different levels of importance to boxes so some will expand to fill blank space while others do not. There are a lot of excellent examples you can use to learn at css-tricks here http://css-tricks.com/snippets/css/a-guide-to-flexbox/
I am not sure I understand what you are trying to achieve so I added this to the CSS based on my understanding:
.ioholder {
display:inline-block;
text-align:center;
padding:10px;
}
.ioholder > .imghold{
float: left;
}
I recommend you tou use grid system, for example Yui3 Grid - http://yuilibrary.com/yui/docs/cssgrids/ - or some other grid system.
.imghold{
margin: 5px;
border: 1px solid black;
height: 100px;
}
.container{
width: 90%;
margin-left: auto;
margin-right: auto;
}
.ioholder{
width: 100%;
background-color: #eee;
}
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.18.1/build/cssgrids/cssgrids-min.css">
<div class='ioholder'>
<div class='yui3-g container'>
<div class="yui3-u-1-6"><div class="imghold">one</div></div>
<div class="yui3-u-1-6"><div class="imghold">two</div></div>
<div class="yui3-u-1-6"><div class="imghold">three</div></div>
<div class="yui3-u-1-6"><div class="imghold">four</div></div>
<div class="yui3-u-1-6"><div class="imghold">five</div></div>
<div class="yui3-u-1-6"><div class="imghold">six</div></div>
</div>
</div>
You can also use responsive grid:
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.18.1/build/cssgrids-responsive/cssgrids-responsive-min.css">
and then
<div class='yui3-g-r'>
<!- ... ->
</div>
Related
Hi i'm sure this has been answered but i can't seem to find what i'm looking for. I would like to have a container with a max-width and margin auto and then inside two divs floated next to each other (both taking 50% of the container) but the one on the right bleeds out the container right to the edge of the viewport?
As below with the dotted white line being the container and the black the browser.
[example here][1]
edit - sorry i forgot to mention the divs need to both be the same height, so if the left has less content than the right it needs to still be the same height as the right, much like if i made them table-cell's.
.container {
margin-left: auto;
margin-right: auto;
max-width: 1260px;
}
.table{
display:table;
table-layout: fixed;
width:100%;
.left, .right{
display:table-cell;
vertical-align: top;
width:50%
}
}
html
<div class="container">
<div class="table">
<div class="left">
content
</div>
<div class="right">
content
</div>
</div>
</div>
I have tried adjusting it based on this answer but it stacks
http://jsfiddle.net/gxG4W/2/
You should try bootstrap for this.
I hope this will help you.
Check out this by maximizing browser window.
Bootstrap Column
.container {
border: solid;
}
h4 { margin-bottom: 30px; }
.row {
margin-bottom: 20px;
}
.row .row {
margin-top: 10px;
margin-bottom: 0;
}
.left-div
{
border: solid red;
}
.right-div
{
border: solid green;
}
<div class="container text-center">
<div class="row">
<h4>Two Columns</h4>
<div class="col-lg-6 col-md-6 left-div">
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
</div>
<div class="col-lg-6 col-md-6 right-div">
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
<p>
test div
</p>
</div>
</div>
</div>
ok i've pretty much fixed this myself now, i'm not sure if its the best way to do it and it doesn't make the div's equal height as with the table trick, so i will need to us js to do that i guess. But here is my solution.
<div class="container">
<div class="left">
Lorem ipsum dolor sit amet
</div>
<div class="right">
Lorem ipsum dolor sit amet
</div>
</div>
css
.container{
max-width:500px;
margin:0 auto;
background:red;
padding:10px 0;
}
.container::after{
content:" ";
clear:both;
display:block;
float:none;
}
.left{
float:left;
width:50%;
background:green;
}
.right{
background:blue;
width:50vw;
margin-left:50%;
}
https://jsfiddle.net/shbkxcgw/4/
I am trying to build a form to add new users to some kind of entity. The idea is to have user avatars in a line and on the end of the line there is a input-field with a typeahead to insert new users.
I tried this some years ago and ended up using javascript as I was not able to do this in plain css (2).
The big question: is this somehow possible in css3?
Basic idea of code:
<div class="availableWidth">
<div class="list">
<ul>
<li><div class="avatar">...</div></li>
...
</ul>
</div>
<div class="form">
<div class="typeaheadField">
<input ...>
</div>
<button>+</button>
</div>
</div>
CSS:
.list ul li {
list-style-type:none;
display:inline-block;
}
button {
width:50px;
}
Basic Idea is that the box .availableWidth has some width (100%) the box .list grows in width (when new li items are added) as the box .form should shrink in width. Right to the input is a some pixels wide button. The input should take the remaining space.
Is that possible in css3 or will I need Javascript?
You can use flexbox, or you can use display table attributes in CSS. Take a look:
.container {
display: table;
width: 100%;
position:relative;
}
.avatar {
width: 50px;
height: 50px;
display: table-cell;
}
.input {
height: 50px;
display:table-cell;
vertical-align: middle;
}
.input input {
width: 100%;
box-sizing: border-box;
padding: 5px;
}
<div class="container">
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="input">
<input type="text"/>
</div>
</div>
<div class="container">
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="input">
<input type="text"/>
</div>
</div>
You can add all the avatars that you want at left side and the input rearrange automatically.
You want to make input 100% width relative to some container from avatars to button. You can get it by using table, flexboxes or formatting contexts and floats.
Here is last one http://jsfiddle.net/53f0yzeL/
Notice overflow:hidden rule for .avatars-wrapper, it make container to fit exactly between floated elements and .avatars side so you can make input 100% wide.
I am having trouble to put in horizontal lines between 2 images. Not sure how to go about doing this as I have just started learning Bootstrap.
I would like to achieve like the below image:
http://i.stack.imgur.com/9vJdm.png
Just have a look at this code will be useful for you
<style>
img{
width:10%;
display:inline-block;
}
.col-lg-5, .col-lg-2{
padding-left:0px;
padding-right: 0px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-5" style="text-align:right">
<img src="path/img1.jpg">
</div>
<div class="col-lg-2">
<hr>
</div>
<div class="col-lg-5">
<img src="path/img2.jpg">
</div>
</div>
</div>
</body>
Based on the size of the image(default) you can change width and col-lg-, col-md-, col-sm-, col-xs- values and also CSS. Its working fine for me.
I'm trying to create a a table using a series styled div ID's in CSS. I'm having real trouble styling the divs. Could someone tell me if I'm approaching this the correct way?
Baring in mind the 'table' will be used to retrieve live data, well hopefully! so I may need the column widths to automatically adjust to fit the character length of a generated string.
-----------------------------------------------------------------------------------------
Top Column
-----------------------------------------------------------------------------------------
Column one | Column two | Column Three
HTML
<div id="container">
<div id="top_row">
<h3>Top row</h3>
</div>
<div id="column_one">
<h3>column one</h3>
</div>
<div id="column_two">
<h3>column two</h3>
</div>
<div id="column_three">
<h3>column three</h3>
</div>
</div>
CSS
#container {
display: table;
border:1px solid #dedede;
}
#top_row {
display: table-row;
}
#column_one, #column_two, #column_three {
display: inline-block;
text-align: center;
margin-top:50px;
margin-left: auto;
margin-right: auto;
letter-spacing:1.5px;
I don't see why not. I'd add a proper row for the bottom part, though:
http://jsfiddle.net/isherwood/jcg8Y/
<div id="container">
<div id="top_row">
<h3>Top row</h3>
</div>
<div id="bottom_row">
<div id="column_one">
<h3>column one</h3>
</div>
<div id="column_two">
<h3>column two</h3>
</div>
<div id="column_three">
<h3>column three</h3>
</div>
</div>
</div>
I have a really, really simple CSS question that has already been asked here a thousand times already in different forms, and seems to have no definitive answer.
I just want to create three columns on an HTML page, using CSS. Doesn't matter about fixed-width versus liquid: just need three columns.
Here's a complete HTML page:
<html>
<body>
<div id="left" style="float:left; width:300px;">
<h3>Column 1</h3>
</div>
<div id="right" style="float:right; width:300px;">
<h3>Column 3</h3>
</div>
<div id="middle">
<h3>Column 2</h3>
</div>
</body>
</html>
In Chrome, at least, this is pushing the left & right columns down below the middle. What is wrong?
like this?: http://jsfiddle.net/SebastianPataneMasuelli/Xu5c6/
just float everything left, and have the columns flow in the normal order in your HTML.
<div id="left">
<h3>Column 1</h3>
</div>
<div id="middle">
<h3>Column 2</h3>
</div>
<div id="right">
<h3>Column 3</h3>
</div>
css:
#left {
background-color: red;
float:left;
width:200px;
}
#middle {
background-color: salmon;
float:left;
width:200px;
}
#right {
background-color: pink;
float:left;
width:200px;
}
if you don't want them to wrap, you can wrap a container div around them, or use
body {
width: 600px; /*combined width of three columns*/
margin: 0 auto;
}
http://jsfiddle.net/SebastianPataneMasuelli/Xu5c6/1/
float is sensitive to order. Put the left, then middle, then right.
Have you tried floating the middle section too?
You might try this
<html>
<body>
<div id="left" style="float:left; width:300px;border:1px solid black;">
<h3>Column 1</h3>
</div>
<div id="middle" style='float:left;width:600px;border:1px solid black;'>
<h3>Column 2</h3>
</div>
<div id="right" style="float:left; width:300px;border:1px solid black;">
<h3>Column 3</h3>
</div>
</body>
</html>