Hey im trying to make a floating grid that has different shapes.
Here is my goal and whats happening: http://imgur.com/a/wXQfA
As you can see there is a gap under the horizontal piece. Im trying to fix it without having to use any positioning so that I can add boxes on later or move them around.
Code:
Html
<li class="mediumBox">
<img src="..." height="205" width="430">
</li>
<li class="largeBox">
<img src="..." height="430" width="430">
</li>
<li class="verticleMediumBox">
<img src="..." height="430" width="205">
</li>
<li class="smallBox">
<img src="..." height="205" width="205">
</li>
<li class="smallBox">
<img src="..." height="205" width="205">
</li>
<li class="smallBox">
<img src="..." height="205" width="205">
</li>
<li class="smallBox">
<img src="..." height="205" width="205">
</li>
</ul>
</div>
</body>
Css:
body{
background-color: #fffdf9;
height: 100%;
width: 100%;
}
#content{
background-color: red;
height: auto;
width: 900px;
margin: 5em auto 0 auto;
}
#work ul{
list-style: none;
}
#work li{
float: left;
margin: 10px;
}
#work li >a{
display: block;
}
#work li .smallBox{
float: left;
display: block;
}
#work li .mediumBox{
float: left;
display: block;
}
#work li .verticleMediumBox{
float: left;
display: block;
}
#work li .largeBox{
float: left;
display: block;
}
Here is my code:http://jsfiddle.net/jw7pV/
For some reason the jsFiddle version doesn't look like my chrome version.
Edit: sorry didn't read the first time that you need dynamic boxes.
If the size of your columns scales (like some kind of responsive design) then you need something that will set these absolute positions dynamically. So you need javascript.
For that you can use jquery masonry or jquery isotope.
http://masonry.desandro.com/
http://isotope.metafizzy.co/
:)
Related
So I'm making a little website to market an application I'm going to create. I'd like to have three social media icons at the bottom of the screen, aligned to the middle of the screen, horizontally.
I've put the three icons inside a div and no matter how much I try, I can't figure out how to align this properly!
Please note, I began using HTML and CSS today, so excuse my extremely horrible code.
<div style="text-align:middle">
<ul style="white-space:nowrap; display:inline; list-style:none;">
<li style="white-space:nowrap; display:inline; list-style:none; padding:30px;">
<img src="images/custom/facebook.png" height="60"></img></li>
<li style="white-space:nowrap; display:inline; list-style:none; text-align:center;">
<img src="images/custom/twitter.png" height="60"></img></li>
<li style="white-space:nowrap; display:inline; list-style:none; padding:30px;">
<img src="images/custom/gmail.png" height="60"></img></li>
</ul>
</div>
Any help is appreciated.
Thank you,
David
You need to use text-align:center:
<div style="text-align:center">
<ul style="white-space:nowrap; display:inline; list-style:none;">
<li style="white-space:nowrap; display:inline; list-style:none;
padding:30px;">
<img src="http://placehold.it/60" height="60" /></li>
<li style="white-space:nowrap; display:inline; list-style:none; text-
align:center;">
<img src="http://placehold.it/60" height="60" /></li>
<li style="white-space:nowrap; display:inline; list-style:none;
padding:30px;">
<img src="http://placehold.it/60" height="60" /></li>
</ul>
</div>
I would use flex boxes to center your div. It's a more modern solution that also scales nicely if you want to play around with your flex-items.
<div style="display: flex; justify-content: center;">
<ul style="white-space:nowrap; display:inline; list-style:none;">
<li style="white-space:nowrap; display:inline; list-style:none;
padding:30px;">
<img src="images/custom/facebook.png" height="60"></li>
<li style="white-space:nowrap; display:inline; list-style:none; text-
align:center;">
<img src="images/custom/twitter.png" height="60"></li>
<li style="white-space:nowrap; display:inline; list-style:none;
padding:30px;">
<img src="images/custom/gmail.png" height="60"></li>
</ul>
</div>
You can learn more about flex boxes here. Alternatively if you're more of a gamer there's an interactive tutorial here.
First, separate your html and css. Second, I doubt that you need the ul and li's. Here's the html:
<div class="social">
<img src="images/custom/facebook.png" class="social-icon">
<img src="images/custom/twitter.png" class="social-icon">
<img src="images/custom/gmail.png" class="social-icon">
</div>
Then, the css:
.social {
text-align: center; //not middle
}
.social-icon {
height: 60px;
padding: 20px; // your choice here
float: left;
}
Even better would be to use the flex property in css:
.social {
display: flex;
padding: 10px; // your choice here
}
.social-icon {
flex: 1 0 30%; // experiment with the last value
padding: 20px; // your choice here as well
}
You can do it with the Flexbox:
* {margin: 0; padding: 0; box-sizing: border-box}
ul {
display: flex; /* displays flex-items (children) inline */
justify-content: center; /* centers them horizontally */
background: Lavender;
}
ul, li {
white-space: nowrap;
}
ul li {
list-style: none;
padding: 30px;
}
img {
height: 60px;
}
<div>
<ul>
<li>
<img src="http://placehold.it/60x60" alt="">
</li>
<li>
<img src="http://placehold.it/60x60" alt="">
</li>
<li>
<img src="http://placehold.it/60x60" alt="">
</li>
</ul>
</div>
I would like to cover the image on of my page the full width of the screen. (so not the whole screen but only the width) and if possible I would also like if the image shrinks if the screen gets smaller. I never did this before so i don't really know how I can make this? Can anybody help me?
this is how my page currently looks like
#charset "UTF-8";
body {
background-color: #ADF1F5;
}
html, body{
margin: 0;
padding: 0;
}
#Anouk {
text-align: center;
margin: 0 auto;
padding: 0;
}
#Anouk img{
display: block;
}
#header {
height: 80px;
background: #000000;
}
li {
display: block;
float: left;
}
li a {
color: #FFFFFF;
height: 80px;
}
#contact {
float: right;
}
<div id="Anouk">
<img src="logo/Hout.png" width="1000px" alt="Logo" />
</div>
<div id="header">
<div id="menu">
<!--Home-->
<li id="home">
<a href="index.html">
<img src="Iconen/Home.png" height="80px" alt="home" onmouseover="this.src='Iconen/Home2.png'" onmouseout="this.src='Iconen/Home.png'" />
</a>
</li>
<!--Over Mij-->
<li id="over">
<a href="over.html">
<img src="Iconen/Over.png" height="80px" alt="home" onmouseover="this.src='Iconen/Over2.png'" onmouseout="this.src='Iconen/Over.png'" />
</a>
</li>
<!--Portfolio-->
<li id="portfolio">
<a href="portfolio.html">
<img src="Iconen/Portfolio.png" height="80px" alt="home" onmouseover="this.src='Iconen/Portfolio2.png'" onmouseout="this.src='Iconen/Portfolio.png'" />
</a>
</li>
<!--Contact-->
<li id="contact">
<a href="contact.html">
<img src="Iconen/Contact.png" height="80px" alt="home" onmouseover="this.src='Iconen/Contact2.png'" onmouseout="this.src='Iconen/Contact.png'" />
</a>
</li>
</div>
</div>
You need to set your img to width="100%" or set a css class on the image for whatever %.
And you need to add:
margin: 0px;
padding: 0px;
To The body because some Browsers (like chrome) are having a standard margin and padding.
PS: I wanted to comment but I cant because my Reputation is to low :(
Is there a simple way in CSS to position a number of images—stacked vertically—on the right) of a variable-sized image. The variable-sized image has a max-width defined that should be relative to the size of the browser window (i.e. it should be as big as possible to not fall off the screen, but not bigger than the actual image pixel dimensions). To make this more difficult, the markup is such that all <img>s are listed as equals, i.e., the images to appear on the right are not in a separate container.
Using a markup like the following, the size of each image is about equal.
<ul>
<li><img/></li> <!-- the big image -->
<li><img/></li>
<li><img/></li>
etc...
</ul>
By request, in a jsFiddle: http://jsfiddle.net/2p9gR/
It would be nice to do this in pure CSS(3), I don't need to support any browsers except my own (the latest Chrome).
Oh. And I will accept "no" for an answer, if it is the truth.
given your picture I have come up with the following solution:
HTML
<div class="container">
<div class="main-image"><img src="http://lorempixel.com/800/800/sports/1/" /></div>
<ul class="small-image-list">
<li><img src="http://lorempixel.com/120/120/sports/2/" /></li>
<li><img src="http://lorempixel.com/120/120/sports/3/" /></li>
<li><img src="http://lorempixel.com/120/120/sports/4/" /></li>
<li><img src="http://lorempixel.com/120/120/sports/5/" /></li>
</ul>
</div>
CSS
.container {padding-right:150px;}
.container .main-image {width:100%; float:left;}
.container .main-image img {width:100%; max-width:800px; max-height:800px;}
.small-image-list {list-style:none; margin:0 -150px 0 0; padding:0; width:120px; float:right;}
.small-image-list li {width:100%; overflow:hidden; padding-bottom:10px;}
#media all and (min-width: 950px) {
/*this is optional if you want the images to stick left when the page is over 950px;*/
.container {padding:0;}
.container .main-image {width:800px;}
.small-image-list {margin:0 0 0 30px; float:left;}
}
Example
Delete the media query if you want the large gutter
EDIT
Given the need for it all to be in a list you can try this:
HTML
<ul class="list">
<li><img src="http://lorempixel.com/800/800/sports/2/" /></li>
<li><img src="http://lorempixel.com/120/120/sports/3/" /></li>
<li><img src="http://lorempixel.com/120/120/sports/4/" /></li>
<li><img src="http://lorempixel.com/120/120/sports/5/" /></li>
</ul>
CSS
.list {list-style:none; padding:0 150px 0 0; margin:0;}
.list li {width:120px; float:right; padding:0; display:block; overflow:hidden; margin-right:-150px;clear:right; display:block;}
.list li:first-child {width:100%; float:left; margin:0; padding:0;}
.list li:first-child img {width:100%; max-height:800px; max-width:800px;}
List Example
Here is a partial solution. I needed to consider two cases that depend on the aspect ratio of the large image, portrait and landscape.
Case 1 - Portrait
<ul class="portrait">
<li class="first">
<img src="http://placekitten.com/300/1000" />
</li>
<!-- the next two images should 'float' right of the first one -->
<li>1
<img src="http://placekitten.com/800/600" />
</li>
<li>2
<img src="http://placekitten.com/800/560" />
</li>
</ul>
ul.portrait {
list-style: none;
border: 1px solid blue;
margin: 0;
padding: 0;
float: left;
}
ul.portrait li {
border: 1px dotted red;
width: 120px;
float: right;
clear: right;
margin-left: 30px;
}
ul.portrait li img {
width: 100%;
}
ul.portrait li.first {
float: left;
width: auto;
border: 1px dashed blue;
margin: 0;
}
ul.portrait li.first img {
vertical-align: top;
height: 100%;
max-height: 800px;
}
Case 2 - Landscape
<ul class="landscape">
<li class="first">
<img src="http://placekitten.com/1000/500" />
</li>
<!-- the next two images should 'float' right of the first one -->
<li>1
<img src="http://placekitten.com/800/600" />
</li>
<li>2
<img src="http://placekitten.com/800/560" />
</li>
<li>3
<img src="http://placekitten.com/800/560" />
</li>
<li>4
<img src="http://placekitten.com/800/560" />
</li>
<li>5
<img src="http://placekitten.com/800/560" />
</li>
<li>6
<img src="http://placekitten.com/800/560" />
</li>
</ul>
ul.landscape {
list-style: none;
border: 1px solid blue;
margin: 0;
padding: 0;
float: left;
}
ul.landscape li {
border: 1px dotted red;
width: 120px;
float: right;
clear: right;
margin-left: 30px;
}
ul.landscape li img {
width: 100%;
}
ul.landscape li.first {
float: left;
width: auto;
border: 1px dashed blue;
margin: 0;
}
ul.landscape li.first img {
vertical-align: top;
width: 100%;
max-width: 600px;
}
It is possible to get the images appearing in the correct configuration, bit there are some limitations.
Since floats are being used, as you make the screen more narrow, the right hand thumbnails will eventually stack below the large image. This suggests specifying a min-width for the parent ul containing block.
See Fiddle: http://jsfiddle.net/audetwebdesign/rsqW3/
The gist of the problem is in the rule for the large image. In the portrait case, you need to specify height: 100% and max-height: 800px and for the landscape case, you need to specify width: 100% and max-width: 600px. You can't quite make this distinction using CSS alone. The calc() value may be of some help but it is not yet widely supported.
I can't for the life of me get a set of images to line up on screen horizontally.
#full_image {
margin: 0;
padding: 0;
list-style: none;
white-space: nowrap;
overflow: hidden;
position: absolute;
}
#full_image ul li img {
display: inline;
margin: 0 auto;
width: 100%;
max-width: 100%
}
<div id="full_image">
<ul>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
<ul>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
<ul>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
</div>
You're creating a new list with each image, for starters; and each list is a block-level (not inline) element. Block elements start on a new line, by default.
Then, your display: inline is applied to the images, not to the li that contains them, which is still at block level.
Finally, list-style: none doesn't make sense on a div. I assume you mean to apply it to a list.
So:
#full_image {
margin: 0;
padding: 0;
list-style: none;
white-space: nowrap;
overflow: hidden;
position: absolute;
}
#full_image li {
display: inline;
}
#full_image li img {
margin: 0 auto;
max-width: 100%
}
<ul id="full_image">
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
remove tags ul li and try again
Remove the list tags
http://jsfiddle.net/cxfNb/ they line up fine. If you want the bullet points, you'll have to remove the block style of the ul and li tags
<div id="full_image">
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</div>
I am attempting to make a simple navigation bar using 4 images, wrapped inside an unordered list.
I am having issues, because the bar is not lining up, it is acting as if the parent div it is nested within has a padding-left assigned to it and pushing the unordered list to the right. Here's a picture of what is happening:
I have a border on the main navigation div to see what is going on.
Here is my code:
<div id="container">
<div id="header">
<h1 class="hidden">Blue Ridge Fencing</h1>
</div>
<div id="navigation">
<ul>
<li><img src="images/website_build/nav_bar/home.jpg" width="208" height="50" alt="Home" border="0"></li>
<li><img src="images/website_build/nav_bar/about.jpg" width="227" height="50" alt="About" border="0"></li>
<li><img src="images/website_build/nav_bar/contact_us.jpg" width="290" height="50" alt="Contact Us" border="0"></li>
<li><img src="images/website_build/nav_bar/quote.jpg" width="235" height="50" alt="Quote" border="0"></li>
</ul>
</div>
<div id="content">
</div>
</div>
And the CSS:
#navigation {
height: 50px;
width: 1000px;
background-image: url(../images/backgrounds/otis_redding.png);
overflow: hidden;
padding: 0px;
border: 1px solid #000;
}
#container #navigation ul {
margin: 0px;
list-style-type: none;
font-size: 34px;
}
#container #navigation li {
float: left;
}
Thank you in advance!
<ul> elements generally have default padding set by the browser (or one of your stylesheets). Just remove it:
#navigation ul {
padding:0;
}
You might want to look into using a CSS reset if you haven't already:
https://stackoverflow.com/questions/167531/is-it-ok-to-use-a-css-reset-stylesheet
Why is there the need for browser resets?
You need to remove the padding from the ul element. You can do by adding padding: 0; to #container #navigation ul in your css.