I made a second background image but no matter what elements I change it doesn't seem like I can position it at all. On top of that when I go into Chrome and use inspect then remove the layer it doesn't disappear?
And another problem I'm having is trying to figure out what code I need to change to get everything centered in the page layout. Like do I just have the numbers wrong or something?
If anyone could help me out I would be super grateful.
My Code:
/*The Main Background*/
body {
background-image: url(../img/background.png);
background-repeat: repeat-x
}
#HeaderBike {
background-image: url(..img/HeaderBike.png);
background-repeat: no-repeat;
z-index: 1;
float: left;
position: absolute height: 155px;
width: 155px;
}
.container {
width: 960px;
margin: 0 auto;
font-family: 'Montserrat', sans-serif;
font-size: 100%;
line-height: 1.5;
text-align: center;
}
/* Nav Element */
/*The Search Bar */
form div {
/*Margin Header */
48px;
float: left;
}
.site-navigation {
height: 155px;
}
.site-navigation img {
margin-top: 16px;
float: left;
}
.site-navigation ul {
width: 600px;
margin: 0 auto;
}
.site-navigation li {
margin: 35px 33px;
float: left;
}
.site-navigation a {
color: white;
text-decoration: none;
font-weight: bold;
}
.site-navigation a:hover {
padding-bottom: 2px;
border-bottom: 1px solid white;
}
/* Header Element */
h2 {
line-height: 0.8;
font-size: 72px;
font-weight: bold;
color: #fff;
width: 450px;
margin: left;
margin-top: 115px;
padding-bottom: 42px;
float: left;
text-align: left;
}
h1 {
text-align: left;
}
.SearchGlass {
margin: -142px 900px;
float: left;
}
/* Class For Articles*/
.article {
float: left;
width: 100%;
margin-bottom: 72px
}
.article img {
width: 20%;
margin-right: 1%
}
.article h1 {
float: left;
width: 70%;
margin: 5px 0;
text-align: left;
font-weight: bold;
font-size: 22.5px;
}
.article p {
float: left;
width: 70%;
margin: 5px 0;
text-align: left;
font-weight: bold;
font-size: 12px;
}
footer {
display: block;
width: 100%;
float: left;
}
.search {
margin: -141px 1125px;
float: left;
}
.RoadToYellow {}
<div class="container">
<header class="Team Sky">
<nav class="site-navigation">
<img src="img/TeamSkyLogo.png" alt="Team Sky Logo">
<ul class="clearfix">
<li>shop</li>
<li>checkout</li>
<li>video</li>
<li>
</div>
</ul>
<div class="SearchGlass" id="SearchGlass">
<img src="img/magnifyingglass.png" alt="Magnifying Glass">
</div>
<form>
<div class="search">
<input id="search" type="text" name="search" placeholder="search"><br>
</div>
<div id="HeaderBike">
<img src="img/HeaderBike.png" alt="Dude on a bike">
</div>
</nav>
</form>
<div class="TeamSkylogo">
<h2>Team Sky</h2>
</div>
<div class="RoadToYellow">
<P>the road to yellow</P>
</div>
<!--Shop Team Sky!-->
<main>
<h1> TEAM NEWS </h1>
<!-- each article/blog should be in it's own container -->
<div class="article">
<img src="img/ArticleImageOne.png" alt="Water">
<h1>Giro d'Italia</h1>
<P>Landa will lead the team on the back of his assured and impressive win at the giro del Trentino, and he returns to the race having excelled last year, when he won</P>
<!--readon !-->
</div>
<div class="article">
<img src="img/ArticleImageTwo.png" alt="Bikes by River">
<h1>Krudder Gets a Break</h1>
<P>The powerful German who was a rock in the beginning of the season will now get a break from and is expected to return for the Malecour at the end of the season</P>
<!--readon !-->
</div>
<div class="article">
<img src="img/ArticleImageThree.png" alt="Bike Dudes Biking">
<h1>Kinnick's New Contract</h1>
<P>Peter Kinnick contract is still not settled with the team manager Alistar McDowell saying that a new contract offer has been made</P>
<!--readon !-->
</div>
<div class="article">
<img src="img/ArticleImageFour.png" alt="Single Guy On Bike">
<h1>Froom In Third</h1>
<P>Chris Froom Finished Third in the opening prologue stage at the Criterium du Dauphine with a strong showing on the first day</P>
<!--readon !-->
</div>
</main>
<footer>
<img src="img/sponsor1.png" alt="Team Sky Sponsor">
<img src="img/sponsor2.png" alt="Pinarello">
<img src="img/sponsor3.png" alt="Shimano">
<img src="img/sponsor4.png" alt="Rayha">
<img src="img/sponsor5.png" alt="21ST Century Fox">
</footer>
</div>
What its suppose to look like
Vs.
What Mine Looks Like
Try using: background-size: cover;
What this will do is amplify the image enough so it covers the container is in.
Also, if you want to center the image you can use: background-position: center;
At the end it would look something like this:
#HeaderBike {
background-image: url(..img/HeaderBike.png);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
z-index: 1;
float: left;
position: absolute height: 155px;
width: 155px;
}
Or more simplified:
#HeaderBike {
background: url(..img/HeaderBike.png) no-repeat cover center;
z-index: 1;
float: left;
position: absolute height: 155px;
width: 155px;
}
Different approach (with flexbox)
Structure HTML
<!-- Header with logo, links and search -->
<header></header>
<!-- Intro section -->
<section></section>
<!-- Main with images and articles -->
<main></main>
<!-- Footer with customers and navigation -->
<footer></footer>
Think in sections, columns and rows.
<div class="section>
<div class="row">
<div class="column"></div>
</div>
</div>
Be consistent!
Give each section the padding you want. Make a row with
.row {
display: flex;
}
and a column with
.column {
flex: 1
}
so that every column has the same width.
Center horizontally and vertically as follows:
/* Center vertically */
.v-centered {
align-items: center;
}
/* Center horizontally */
.centered {
justify-content: center;
}
Example
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Montserrat', sans-serif;
}
a {
text-decoration: none;
}
.text-center {
text-align: center;
}
header {
background: #49B2CB;
}
header a {
color: white;
}
.container {
max-width: 960px;
margin: 0 auto;
border: 1px solid;
}
.section {
padding: 3rem 1.5rem;
}
/* Make header and footer padding not as big as normal */
header.section,
footer.section {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}
/* Row, centering, wrapping */
.row {
display: flex;
margin: 0 -0.75rem;
}
.row.v-centered {
align-items: center;
}
.row.centered {
justify-content: center;
}
.row.wrap {
flex-wrap: wrap;
}
.row>.column {
flex: 1;
}
.row>* {
padding: 0.75rem;
}
/* Navigation */
ul.nav {
padding: 0;
margin: 0;
list-style: none;
}
ul.nav li {
float: left;
padding: 5px;
}
ul.nav a {
color: #797979;
}
/* Buttons */
.btn {
text-decoration: none;
display: inline-block;
padding: 0.5rem;
border-radius: 0.5rem;
color: white;
}
.btn.light {
background: #49B2CB;
}
.btn.dark {
background: #000000;
}
/* Intro */
.intro {
background-image: url(http://lorempixel.com/960/400/sports/1);
color: white;
text-align: center;
}
.intro h1 {
font-size: 3rem;
margin: 0;
}
/* Main */
main h2 {
margin: 0.5rem 0;
}
/* Make main images responsive */
main img {
display: block;
height: auto;
max-width: 100%;
}
/* Footer */
footer figure {
margin: 0;
}
footer .nav {
text-align: center;
}
#media screen and (max-width: 767px) {
main .row {
flex-direction: column;
}
}
<div class="container">
<header class="section">
<div class="row v-centered centered">
<div class="column"><img src="http://via.placeholder.com/200x50?text=TEAM-SKY" alt=""></div>
<div class="column text-center">shop</div>
<div class="column text-center">checkout</div>
<div class="column text-center">video</div>
<div class="column"><input type="text" placeholder="Search ..."></div>
</div>
</header>
<section class="section intro">
<div class="row v-centered">
<div>
<h1>Team Sky</h1>
<p>the road to yellow</p>
shop team sky
</div>
</div>
</section>
<main class="section">
<h2>TEAM NEWS</h2>
<div class="row">
<div class="column"><img src="http://via.placeholder.com/400x200" alt="">
</div>
<div class="column">
<article>
<h3>Heading 1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat eligendi voluptas voluptate ut distinctio aspernatur perferendis minima, repellendus consequatur, incidunt, velit ipsum est suscipit veniam fugiat tempora, rem dolore! Commodi?</p>
More
</article>
</div>
</div>
<div class="row">
<div class="column"><img src="http://via.placeholder.com/400x200" alt="">
</div>
<div class="column">
<article>
<h3>Heading 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos, reiciendis dolor nulla maiores! Eaque quaerat quas optio quam odio inventore totam odit nobis blanditiis facere iure rem, praesentium et similique.</p>
More
</article>
</div>
</div>
<div class="row">
<div class="column"><img src="http://via.placeholder.com/400x200" alt="">
</div>
<div class="column">
<article>
<h3>Heading 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempore illo mollitia consequatur laborum nulla, eos incidunt iusto explicabo voluptate molestias dolorum dolores, at, dolor temporibus ex tenetur quaerat, ducimus sequi.</p>
More
</article>
</div>
</div>
<div class="row">
<div class="column"><img src="http://via.placeholder.com/400x200" alt="">
</div>
<div class="column">
<article>
<h3>Heading 4</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit impedit amet odio quaerat sit voluptates aut quisquam tempore ipsa repellat ipsam atque deserunt, quis voluptatum quos aliquid laudantium dolorum accusamus.</p>
More
</article>
</div>
</div>
</main>
<footer class="section">
<div class="row centered wrap">
<figure><img src="http://via.placeholder.com/100x50?text=Customer 1" alt="">
</figure>
<figure><img src="http://via.placeholder.com/150x50?text=Customer 2" alt="">
</figure>
<figure><img src="http://via.placeholder.com/75x50?text=Customer 3" alt="">
</figure>
<figure><img src="http://via.placeholder.com/100x50?text=Customer 4" alt="">
</figure>
<figure><img src="http://via.placeholder.com/200x50?text=Customer 5" alt="">
</figure>
</div>
<div class="row centered">
<ul class="nav">
<li>Link 1
</li>
<li>Link 2
</li>
<li>Link 3
</li>
<li>Link 4
</li>
<li>Link 5
</li>
</ul>
</div>
</footer>
</div>
Related
Used a css template and edited, now between the 3 columns there is a small margin gap which id like to get rid of. tried readjusting the columun sizes but the margin gap still exists. Is there a more simple way I could have achieved the same page, if so how?? Yes im a newbie :P
* {
box-sizing: border-box;
}
body {
margin: 0;
}
/* Style the header */
.header {
background-color: #F1C40F;
padding: 20px;
text-align: center;
}
/* Style the footer */
.footer {
background-color: #F1C40F;
padding: 10px;
text-align: center;
/* Create three unequal columns that floats next to each other */
.column {
float: left;
padding: 10px;
}
/* top, middle and bottom column */
.columntopmiddlebottom {
width: 30%;
}
/* Responsive layout - makes the three columns stack on top of each other
instead of next to each other */
#media screen and (max-width: 600px) {
.column.side,
.column.middle {
width: 100%;
}
}
.auto-style2 {
text-align: center;
}
}
.auto-style2 {
margin-top: 31px;
}
<div class="header">
<h1>Header</h1>
<p>Resize the browser window to see the responsive effect.</p>
</div>
<div class="row" style="height: 717px">
<div class="columntopmiddlebottom" style="background-color:#F7DC6F;
style=" height: 211px>
<h2>People</h2>
<p style="height: 214px">1</p>
</div>
<div class="columntopmiddlebottom" style="background-color:#F7DC6F;
style=" height: 212px>
<h2 style="height: 21px">2</h2>
<p style="height: 171px">info</p>
</div>
<div class="columntopmiddlebottom" style="background-color:#F7DC6F;
style=" height: 212px>
<h2 style="height: 37px">3</h2>
<p style="height: 193px">info</p>
</div>
</div>
Gaps under and above each column appears, dont want the gaps.
Try this:
.columntopmiddlebottom * {
margin-block-start: 0;
margin-block-end: 0;
}
A usefull trick when writing CSS is using the browsers development tools:
In Google when you right click on an element and press Inspect you can see which CSS is on that element. If you can't find the problem you are looking for you can try pressing CTRL + SHIFT + C and go over the elements to find your problem.
Good luck!
It is about https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
The top and bottom margins of blocks are sometimes combined (collapsed) into a single margin whose size is the largest of the individual margins (or just one of them, if they are equal), a behavior known as margin collapsing. Note that the margins of floating and absolutely positioned elements never collapse.
reset margin to hn and p .
* {
box-sizing: border-box;
}
h2,
p {
margin: 0;/* reset margin to avoid collapsing . Note , padding or border on the parent will keep margin inside*/
}
body {
margin: 0;
}
/* Style the header */
.header {
background-color: #F1C40F;
padding: 20px;
text-align: center;
}
/* Style the footer */
.footer {
background-color: #F1C40F;
padding: 10px;
text-align: center;
/* Create three unequal columns that floats next to each other */
.column {
float: left;
padding: 10px;
}
/* top, middle and bottom column */
.columntopmiddlebottom {
width: 30%;
}
/* Responsive layout - makes the three columns stack on top of each other
instead of next to each other */
#media screen and (max-width: 600px) {
.column.side,
.column.middle {
width: 100%;
}
}
.auto-style2 {
text-align: center;
}
}
.auto-style2 {
margin-top: 31px;
}
<div class="header">
<h1>Header</h1>
<p>Resize the browser window to see the responsive effect.</p>
</div>
<div class="row" style="height: 717px">
<div class="columntopmiddlebottom" style="background-color:#F7DC6F;
style=" height: 211px>
<h2>People</h2>
<p style="height: 214px">1</p>
</div>
<div class="columntopmiddlebottom" style="background-color:#F7DC6F;
style=" height: 212px>
<h2 style="height: 21px">2</h2>
<p style="height: 171px">info</p>
</div>
<div class="columntopmiddlebottom" style="background-color:#F7DC6F;
style=" height: 212px>
<h2 style="height: 37px">3</h2>
<p style="height: 193px">info</p>
</div>
</div>
you can use this package https://necolas.github.io/normalize.css/ in css to remove margin and padding for element
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
header {
background-color: #F1C40F;
height: 200px;
text-align: center;
padding: 50px 0;
}
.one {
background-color: #F7DC6F;
height: 200px;
text-align: center;
padding: 50px 0;
}
.two {
background-color: #F1C40F;
height: 200px;
text-align: center;
padding: 50px 0;
}
.three {
background-color: #F7DC6F;
height: 200px;
text-align: center;
padding: 50px 0;
}
.four {
background-color: #F1C40F;
height: 200px;
text-align: center;
padding: 50px 0;
}
footer{
background-color: #F7DC6F;
height: 200px;
text-align: center;
padding: 50px 0;
}
<header>
<h1>Header</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum eum minus aliquam dolorum sit molestiae architecto.</p>
</header>
<section class="one">
<h2>Section One</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum eum minus aliquam dolorum sit molestiae architecto.</p>
</section>
<div class="two">
<h2>Gallery</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum eum minus aliquam dolorum sit molestiae architecto.</p>
</div>
<article class="three">
<h2>News</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum eum minus aliquam dolorum sit molestiae architecto.</p>
</article>
<aside class="four">
<h2>Aside NavBar</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum eum minus aliquam dolorum sit molestiae architecto.</p>
</aside>
<footer >
<h2>Aside NavBar</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Earum eum minus aliquam dolorum sit molestiae architecto.</p>
</footer>
Another simple version using Flexbox.
* {
box-sizing: border-box;
margin: 0;
}
.header {
background-color: #F1C40F;
padding: 20px;
text-align: center;
}
.row {
background-color: #fff;
text-align: center;
display: flex;
flex-direction: row;
}
.column {
flex-grow: 1;
padding: 10px;
background-color:#F7DC6F;
height: 200px
}
#media screen and (max-width: 800px) {
.row {
flex-direction: column;
}
}
<div class="header">
<h1>Header</h1>
<p>Resize the browser window to see the responsive effect.</p>
</div>
<div class="row">
<div class="column">
<h2>People</h2>
<p>1</p>
</div>
<div class="column">
<h2>2</h2>
<p>info</p>
</div>
<div class="column">
<h2>3</h2>
<p>info</p>
</div>
</div>
I need help in centering my image gallery, i cant make it to work how i want, gutters are being pain in the ass and so are calculating margins and widths. I want images centered, so three images per row, with one image being all the way to the left, second image being centered and third image being all the way to the right, using margins and padding with floats individually I believe is a bad practice, there has to be a better way to do this. Each image is 295px width I changed their widths in photoshop. I don't wish to use css grid, flexbox etc… I just want to do it in basic way with floats and box model. If there is any good way to center these images with some space in between them.
/* CSS Document */
/*body {
margin: 20px 250px;
}*/
#wrapper {
width: 1000px;
margin: 20px auto;
}
header {
background-image: url("../Images/view2.jpg");
background-repeat: no-repeat;
text-align: center;
padding-top: 30px;
padding-bottom: 20px;
}
header #navbar {
margin-top: 35px;
}
#navbar a {
padding: 30px 35px;
}
header h1 {
margin: 0;
}
main {
background: rgba(211, 204, 38, 1.00);
overflow: hidden;
padding: 20px;
}
main #page {
text-align: center;
}
main #inner-content ul {
list-style: none;
}
main #inner-content {
overflow: hidden;
padding-left: 17.7px;
}
main #inner-content #block1 {
float: left;
padding: 0;
width: 33.33%;
}
main #inner-content #block2 {
float: left;
padding: 0;
width: 33.33%;
}
main #inner-content #block3 {
float: left;
padding: 0;
width: 33.33%;
}
main #inner-content #block1 li {
margin-left: 12.5px;
}
main #inner-content #block2 li {
margin-left: 12.5px;
}
main #inner-content #block3 li {
margin-left: 12.5px;
}
#about-text {
margin-bottom: 50px;
text-align: center;
}
footer {
background: rgba(96, 96, 96, 1.00);
padding: 20px;
overflow: hidden;
clear: left;
}
footer #contact {
float: left;
margin-left: 200px;
}
footer #form {
float: right;
margin-right: 200px;
}
<div id="wrapper">
<header id="header">
<h1>ISMAR PHOTOGRAPHY</h1>
<nav id="navbar">
HOME
ABOUT
SERVICES
CONTACT
PORTFOLIO
</nav>
</header>
<main>
<p id="about-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nihil error aspernatur vitae illo animi aliquam perferendis dicta, temporibus, dolores suscipit accusantium cumque voluptas nesciunt pariatur numquam omnis quo sunt minus voluptatum vero odio
ipsam mollitia. Itaque consequatur non harum molestias quibusdam voluptatem provident, eius, aliquam magnam, nesciunt ipsum est maiores! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed beatae veritatis provident expedita facere dolore
saepe autem cupiditate voluptas assumenda enim odit illum et placeat amet officiis, accusamus adipisci veniam, hic. Velit fugiat vitae, laboriosam omnis voluptates rem, totam esse quisquam sunt hic voluptatum amet quam repudiandae sequi incidunt
nam!</p>
<p id="page">01</p>
<div id="inner-content">
<ul id="block1">
<li><img src="Images/nature.jpg"></li>
<li><img src="Images/panorama.jpg"></li>
<li><img src="Images/self.jpg"></li>
</ul>
<ul id="block2">
<li><img src="Images/self2.jpg"></li>
<li><img src="Images/sky.jpg"></li>
<li><img src="Images/telex.jpg"></li>
</ul>
<ul id="block3">
<li><img src="Images/urban-beatz.jpg"></li>
<li><img src="Images/urban-beatz2.jpg"></li>
<li><img src="Images/view.jpg"></li>
</ul>
</div>
</main>
<footer>
<div id="contact">
<h2>CONTACT ME</h2>
<p>randomemail#gmail.com</p>
<p>+456 34 55 5567</p>
</div>
<form action="#" name="form" id="form">
<label for="name">Name</label><br>
<input type="text" id="name"><br>
<label for="last-name">Last name</label><br>
<input type="text" id="last-name"><br>
<label for="email">Email</label><br>
<input type="text" id="email"><br>
<label for="message">Message</label><br>
<input type="text" id="message"><br>
</form>
</footer>
</div>
Okay, if you don't want to use grid or flexbox, then I'd suggest the old school table is a good option.
.my-table {
width: 100%;
}
.my-table td {
/* Change this padding to add gutters of desirable size*/
padding: 20px;
}
.my-table img {
width: 100%;
height: auto;
}
<table class="my-table">
<tr>
<td><img src="image_1_location.jpg" /></td>
<td><img src="image_2_location.jpg" /></td>
<td><img src="image_3_location.jpg" /></td>
</tr>
<tr>
<td><img src="image_4_location.jpg" /></td>
<td><img src="image_5_location.jpg" /></td>
<td><img src="image_6_location.jpg" /></td>
</tr>
</table>
Option 2
There is another way you can achieve this with floats if you want.
The only thing is that you'll have to make multiple containers to accommodate for the floats.
Here's how you can do it
.my-image-gallery {
position: relative;
}
.clearfix:after {
content: " ";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
.floating-element {
float: left;
width: 33.33%;
}
.image-container {
padding: 10px;
}
.image-container>img {
width: 100%;
height: auto;
}
<div class="my-image-gallery">
<div id="row-1" class="clearfix">
<!-- You'll need to make a container for each image -->
<div class="floating-element">
<div class="image-container">
<img src="google-logo.png" />
</div>
</div>
<div class="floating-element">
<div class="image-container">
<img src="google-logo.png" />
</div>
</div>
<div class="floating-element">
<div class="image-container">
<img src="google-logo.png" />
</div>
</div>
</div>
</div>
While I think this is a riduculous way of doing this. You can use calc() to add a margin on both sides of the center img this example is using your current markup with no flex:
li:nth-child(2) {
margin: 0 calc(50% - 408px);
}
li {
width: 259px;
height: 259px;
list-style-type: none;
background-color: lightblue;
display: inline-block;
}
https://jsfiddle.net/DIRTY_SMITH/0f78ksvx/12/
The better way that you don't want to do would be to use flex:
#block1{
display: flex;
justify-content: space-between;
}
https://jsfiddle.net/DIRTY_SMITH/0f78ksvx/3/
Below are some minimal examples of how to implement your gallery. The concept is the same for both the Flexbox and Float approaches. Tell each image that it should be 1/3 the width of the container element (including margin) and allow the images to wrap inside their container element.
The overflow and negative margin properties used in both "remove" the outermost margins and may not be something that you desire or are concerned with.
Using Flexbox
body {
margin: 2rem;
}
.container {
margin-left: auto;
margin-right: auto;
width: 75%;
overflow: hidden;
}
.gallery {
display: flex;
flex-wrap: wrap;
align-items: center;
margin: -1rem;
background-color: rgba( 111, 222, 50, 0.15);
}
.gallery img {
display: flex;
margin: 1rem;
width: calc( 33.33333% - 2rem );
}
<div class="container">
<div class="gallery">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/">
</div>
</div>
Using Floats
I highly recommend moving away from floats and using Flexbox or CSS Grid unless there is a specific behavior that floats provide that favors some requirement.
body {
margin: 2rem;
}
.container {
margin-left: auto;
margin-right: auto;
width: 75%;
overflow: hidden;
}
.gallery {
margin: -1rem;
overflow: hidden;
background-color: rgba( 111, 222, 50, 0.15 ); /* For illustrative purposes. */
}
.gallery img {
float: left;
margin: 1rem;
max-width: calc( 33.33333% - 2rem); /* Subtract left and right margins */
}
<div class="container">
<div class="gallery">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/">
</div>
</div>
body {
margin: 2rem;
}
.container {
margin-left: auto;
margin-right: auto;
width: 75%;
overflow: hidden;
}
.gallery {
overflow: hidden; /* For illustrative purposes. */
background-color: rgba( 111, 222, 50, 0.15 ); /* For illustrative purposes. */
}
.gallery img {
float: left;
margin: 1rem;
max-width: calc( 33.33333% - 2rem); /* Subtract left and right margins */
}
<div class="container">
<div class="gallery">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/d10">
<img src="https://via.placeholder.com/300x300/fc0">
<img src="https://via.placeholder.com/300x300/">
</div>
</div>
use the html
<center>
image code here
</center>
<right>
and
<left>
I have a little problem with bootstrap, I test lot of possibility for resolve my problem, but I dont found the good..
I have a footer. The footer is in the container for align with the bootstrap grid. I would like to put the width contact block at 100% at the right.Currently it is blocked against the container.
the block are perfectly align, i have just this problem
Curently:
Final result :
(See my code in full view)
#charset 'UTF-8';
#import url('https://fonts.googleapis.com/css?family=Lato:300,400,900|Merriweather:400,400i,700i');
.accompagnement {
height: 550px;
background: #fafafa;
}
.accompagnement__titre {
font-family: Merriweather, serif;
font-size: 30px;
font-weight: 400;
line-height: 240px;
position: relative;
color: #aba08c;
}
.accompagnement__titre:after {
position: absolute;
right: 40%;
bottom: 70px;
width: 200px;
height: 1px;
content: ' ';
background: #aba08c;
}
.accompagnement__informations {
background: white;
background-clip: content-box;
}
.accompagnement__image {
width: 100%;
height: 210px;
background: url('../assets/img/spot-of-light-1145368.jpg') no-repeat center center;
}
.accompagnement__texte {
line-height: 26px;
padding: 30px 30px;
}
.accompagnement__texte > h2 {
font-size: 24px;
color: #8b3d61;
}
.accompagnement__texte > p {
font-weight: 300;
}
.valign {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.set-relative {
position: relative;
}
.svg-button {
/**
Gestion du :Hover des SVG
*/
}
.svg-button-gauche,
.svg-button-droite {
position: absolute;
top: 50%;
width: 46px;
height: 46px;
fill: #5e5f78;
}
.svg-button-gauche {
left: -60px;
}
.svg-button-droite {
right: -60px;
}
.svg-button-fleche {
fill: none;
stroke: #ccc;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 2px;
}
.svg-button-contour {
fill: #ccc;
}
.svg-button-gauche:hover .svg-button-fleche,
.svg-button-droite:hover .svg-button-fleche {
stroke: red;
}
.svg-button-gauche:hover .svg-button-contour,
.svg-button-droite:hover .svg-button-contour {
fill: red;
}
footer {
position: relative;
background: #e5e3e8;
}
footer ul {
margin: 50px 0 140px 0;
color: #5e5f78;
}
footer ul li {
font-weight: 300;
line-height: 25px;
}
footer ul li:first-child {
font-family: Merriweather, serif;
font-weight: 400;
line-height: 30px;
}
footer ul li a {
text-decoration: none;
color: inherit;
}
footer ul li a:hover {
color: inherit;
}
.footer {
font-size: 13px;
font-weight: 300;
padding: 30px 0;
color: #5e5f78;
border-top: 1px solid #fff;
}
.footer__copyright {
padding-left: 0;
}
.footer__appolo {
padding-right: 0;
text-align: right;
}
.footer__appolo > a {
display: inline-block;
text-decoration: none;
color: #5e5f78;
}
.footer__appolo > a:first-child:after {
margin: 0 15px;
content: '•';
}
.contacts {
position: absolute;
top: -20px;
right: 0;
height: 409px;
background: #fff;
background-clip: content-box;
}
.contacts > h2 {
font-family: Merriweather, serif;
font-size: 30px;
line-height: 30px;
position: relative;
margin-bottom: 55px;
color: #aba08c;
}
.contacts > h2:after {
position: absolute;
bottom: -30px;
left: 0;
width: 300px;
height: 1px;
content: ' ';
background: #aba08c;
}
.contacts__tel {
font-weight: 300;
line-height: 30px;
margin: 0 0 50px 0;
}
.contacts__permanence,
.contacts__disponibilite,
.contacts__lieu {
font-family: Merriweather, serif;
font-size: 14px;
font-weight: 400;
line-height: 30px;
margin: 0;
}
.contacts__adresse {
font-size: 14px;
font-weight: 300;
line-height: 20px;
margin: 0;
color: #5e5f78;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<section class="container-fluid accompagnement">
<div class="container">
<div class="row">
<div class="container">
<div class="row set-relative">
<div class="col-lg-4 accompagnement__informations">
<div class="accompagnement__image"></div>
<div class="accompagnement__texte">
<h2>Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid blanditiis dignissimos fuga nobis, nulla, pariatur, quia quisquam reiciendis repellendus tempore vero voluptas voluptate voluptatibus. Alias ducimus impedit nostrum reprehenderit ut!</p>
</div>
</div>
<div class="col-lg-4 accompagnement__informations">
<div class="accompagnement__image"></div>
<div class="accompagnement__texte">
<h2>Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda consectetur doloribus ducimus eveniet molestiae? Amet delectus, distinctio harum incidunt, laborum libero minima minus molestias quam repudiandae suscipit ut veniam voluptatum.</p>
</div>
</div>
<div class="col-lg-4 accompagnement__informations">
<div class="accompagnement__image"></div>
<div class="accompagnement__texte">
<h2>Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Asperiores cumque eligendi expedita id itaque minus modi neque nostrum odio omnis provident quam quas quasi quisquam ratione repellendus, sapiente similique voluptas.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<footer>
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="row">
<div class="col-lg-3">
<ul class="list-unstyled">
<li>Menu</li>
<li>SubMenu</li>
<li>SubMenu</li>
<li>SubMenu</li>
</ul>
</div>
<div class="col-lg-3">
<ul class="list-unstyled">
<li>Menu</li>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</div>
<div class="col-lg-3">
<ul class="list-unstyled">
<li>Menu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</div>
<div class="col-lg-3">
<ul class="list-unstyled">
<li>Menu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</div>
</div>
<div class="row footer">
<p class="col-lg-6 footer__copyright">© 2017 Company</p>
<div class="col-lg-6 footer__appolo">
Plan
</div>
</div>
</div>
<div class="col-lg-4">
<div class="row">
<div class="col-lg-12 contacts">
<h2>Contacts</h2>
<p class="contacts__permanence">Blablabla</p>
<p class="contacts__disponibilite">Blablabla</p>
<p class="contacts__tel">Blablabla</p>
<p class="contacts__lieu">Blablabla</p>
</div>
</div>
</div>
</div>
</div>
</footer>
</body>
Thanks
If your block is inside a .container, you can't expand it outside the container, unless you make it position:absolute or something like this.
You could also change the .container in the footer into a .container-fluid, and then create 2 blocks inside for placing.
.container is made to be centered on devices > "xs".
I need some help with my footer. I want my text on the right but don't want to push it all in the corner like this. Which happens when you align the text to the right or float the whole div to the right. A margin would be a solution but when i make make my screen smaller the text disappears because the text can't move because of the margin. Thats why I tried to put the text in a div which i set to 25% of the screen. So the text would always take up 25% of the screen. But unfortunately this still doesn't solve my problem because when you make the screen smaller all of the text is now pushed to the bottom.
Does anyone have a working solution for me?
This is how the pages looks right-now (the colors are just there so you can see the divs better)
#charset "UTF-8";
body {
background-image: url("achtergronden/hout.png");
width: 100%;
}
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;
}
#homepagina {
background-image: url("achtergronden/blauw.png");
width: 100%;
height: 473px;
}
#updates {
height:1000px;
}
#laatste {
color: #FFFFFF;
font-family: oswald, sans-serif;
font-size: 30px;
text-align: center;
text-decoration: bold 700;
}
#footer {
position: relative;
}
#A {
height: 80px;
width: 25%;
background: yellow;
float: left;
}
#B {
background: red;
width: 25%;
height: 80px;
float: left;
}
#C {
background: blue;
width: 25%;
height: 80px;
float: left;
}
#D {
background: white;
width: 25%;
height: 80px;
float: left;
}
<div id="Anouk">
<img src="logo/Hout.png" width="100%" 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>
<div id="homepagina">
</div>
<div id="updates">
<p id="laatste">Laatste Updates</p>
</div>
<div id="footer">
<div id="A"></div>
<div id="B"></div>
<div id="C"></div>
<div id="D">
<p id="facebook"> F = ..........</p>
<p id="email"> E = ............</p>
</div>
</div>
You can simply achieve this by adding padding to the element, but I would wrap the paragraphs in a container element and add padding left and right to it. Now your text won't be pushed inside the corner.
This stackoverflow post can give you some more insight. It explains when to use margin and padding and also explains the difference between them.
html, body {
height: 100%;;
}
body {
margin: 0;
}
.content {
height: 100%;
margin-top: 15px;
}
.container {
padding: 0 15px;
}
footer {
background-color: black;
color: white;
padding: 15px 0;
text-align: right;
}
p {
margin: 0;
}
<div class="content">
<div class="container">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum vero doloremque dolorem eveniet odit dolores inventore neque, praesentium quia quaerat maiores eaque, ex sapiente molestiae assumenda illum quo, aperiam! Pariatur voluptatibus, eum alias corporis commodi amet aut distinctio iure atque, animi nisi rerum quae fuga! Harum ratione corporis, neque explicabo.</p>
</div>
</div>
<footer>
<div class="container">
<p id="facebook"> F = ..........</p>
<p id="email"> E = ............</p>
</div>
</footer>
I have this simple html and css (sass) with some nesting, but not much. The problem I have is that in the first big div all sub-elements are displayed inside as they are written, but in the other div (same class) bg-color and margin cover only the heading and not the other elements in that div.
What is happening?
codepen link
* {
box-sizing: border-box;
}
.intro {
position: relative;
display: block;
background: #F3F5F8;
padding: 50px 0;
text-align: center;
color: slategray;
}
.intro:nth-child(2) {
background: #e8e6e3;
}
.intro section {
margin-left: auto;
margin-right: auto;
padding-left: 50px;
padding-right: 50px;
width: 600px;
}
.intro section .column {
position: relative;
float: left;
width: 33.33333%;
padding: 0 20px;
}
.intro section .column .item {
position: relative;
margin: 30px auto;
width: 15px;
height: 15px;
max-width: 100%;
display: block;
background: cadetblue;
border-radius: 50%;
}
.intro section .column h3 {
font: 0.6em "Montserrat", sans-serif;
padding: 0;
margin: 0;
letter-spacing: 0.5em;
}
.intro section .column p {
font: 0.8em/1.8em "Arimo", sans-serif;
padding: 0;
margin: 25px 0;
}
.intro section h2 {
font: 2em "Montserrat", sans-serif;
text-transform: uppercase;
padding: 0;
margin: 0;
}
.intro section h4 {
font: 0.6em "Montserrat", sans-serif;
padding: 0;
margin: 0;
letter-spacing: 0.5em;
}
.intro section p {
font: 0.8em/1.8em "Arimo", sans-serif;
padding: 0 120px;
margin: 45px 0 0;
}
<div class="intro">
<section>
<h4>WHO WE ARE</h4>
<h2>HEADING</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet dolorum voluptas, ullam vero est.</p>
</section>
</div>
<div class="intro">
<section>
<h4>WHAT WE DO</h4>
<h2>HEADING</h2>
<div class="column">
<div class="item"></div>
<h3>ITEM1</h3>
<p>Necessitatibus ipsa ex hic sunt maxime.</p>
</div>
<div class="column">
<div class="item"></div>
<h3>ITEM2</h3>
<p>Molestias ipsum ex deleniti illo qui obcaecati repellat.</p>
</div>
<div class="column">
<div class="item"></div>
<h3>ITEM3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</section>
</div>
Thanks
because your .column divs are float:left; you need a container with clear:both; after the columns:
<section>
<h4>WHAT WE DO</h4>
<h2>HEADING</h2>
<div class="column">
<div class="item"></div>
<h3>ITEM1</h3>
<p>Necessitatibus ipsa ex hic sunt maxime.</p>
</div>
<div class="column">
<div class="item"></div>
<h3>ITEM2</h3>
<p>Molestias ipsum ex deleniti illo qui obcaecati repellat.</p>
</div>
<div class="column">
<div class="item"></div>
<h3>ITEM3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="clearer"></div>
</section>
CSS
.clearer {
clear:both;
}
http://codepen.io/anon/pen/myvwNY
Without the clear the container the floating divs are in has no height.
Think I understand - you have column collapse from the floated column
http://codepen.io/anon/pen/vEbZoP
just add a clear after them like so
<div class="clear"></div>
.clear
clear: both;
This is due to floats of .colomn , you can use conatain float or clearfix techniques
I have listed tow of them below
1) added <p></p> with clear both sides after floated element
2) add overflow:hidden to the parent of floated element (ie )
Read more about clearfix and containing floats
* {
box-sizing: border-box;
}
.intro {
position: relative;
display: block;
background: #F3F5F8;
padding: 50px 0;
text-align: center;
color: slategray;
}
.intro:nth-child(2) {
background: #e8e6e3;
}
.intro section {
margin-left: auto;
margin-right: auto;
padding-left: 50px;
padding-right: 50px;
width: 600px;
}
.intro section .column {
position: relative;
float: left;
width: 33.33333%;
padding: 0 20px;
}
.intro section .column .item {
position: relative;
margin: 30px auto;
width: 15px;
height: 15px;
max-width: 100%;
display: block;
background: cadetblue;
border-radius: 50%;
}
.intro section .column h3 {
font: 0.6em "Montserrat", sans-serif;
padding: 0;
margin: 0;
letter-spacing: 0.5em;
}
.intro section .column p {
font: 0.8em/1.8em "Arimo", sans-serif;
padding: 0;
margin: 25px 0;
}
.intro section h2 {
font: 2em "Montserrat", sans-serif;
text-transform: uppercase;
padding: 0;
margin: 0;
}
.intro section h4 {
font: 0.6em "Montserrat", sans-serif;
padding: 0;
margin: 0;
letter-spacing: 0.5em;
}
.intro section p {
font: 0.8em/1.8em "Arimo", sans-serif;
padding: 0 120px;
margin: 45px 0 0;
}
<div class="intro">
<section>
<h4>WHO WE ARE</h4>
<h2>HEADING</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet dolorum voluptas, ullam vero est.</p>
</section>
</div>
<div class="intro">
<section>
<h4>WHAT WE DO</h4>
<h2>HEADING</h2>
<div class="column">
<div class="item"></div>
<h3>ITEM1</h3>
<p>Necessitatibus ipsa ex hic sunt maxime.</p>
</div>
<div class="column">
<div class="item"></div>
<h3>ITEM2</h3>
<p>Molestias ipsum ex deleniti illo qui obcaecati repellat.</p>
</div>
<div class="column">
<div class="item"></div>
<h3>ITEM3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<p style="clear:both"></p>
</section>
</div>