Floating images and divs - css

I am trying to float one image to the right of an existing div.
The div has a background color and has text and images on top of it.
When I try to float the image to the right of the div, the image appears where the div was, and all the text and images on the div are pushed down.
Not sure why I can't get the image to appear next to the div. Here's my HTML and CSS.
#left-column-background {
width: 40%;
height: 750px;
background-color: #C16C43;
margin-left: 10%;
margin-bottom: 10%;
margin-right: 10%;
float: left;
}
#right-column-image {
background-image: url('resized-images-logo/about-resized.jpg');
background-repeat: no-repeat;
background-size: cover;
width: 40%;
height: 750px;
float: right;
}
#about-title {
color: #C16C43;
margin-top: 7%;
margin-bottom: 5%;
margin-left: 10%;
margin-right: 2%;
}
#mission-text {
margin-top: 5%;
margin-left: 12%;
margin-bottom: 5%;
width: 80%;
float: left;
}
#mission-button-large {
margin-top: 7%;
margin-left: 12%;
float: left;
}
#service-button-large {
margin-top: 12%;
margin-left: 12%;
}
#service-text {
margin-top: 5%;
margin-bottom: 5%;
margin-left: 12%;
width: 80%;
}
#values-button-large {
margin-top: 7%;
margin-left: 12%;
}
#values-button-text {
margin-top: 5%;
margin-bottom: 5%;
margin-left: 12%;
width: 80%;
}
#mission-button-medium {
display: none;
margin-top: 7%;
margin-left: 12%;
float: left;
}
#service-button-medium {
display: none;
margin-top: 12%;
margin-left: 12%;
}
#service-button-small {
margin-top: 12%;
margin-left: 12%;
display: none;
}
#values-button-medium {
margin-top: 7%;
margin-left: 12%;
display: none;
}
#mission-button-small {
margin-top: 7%;
margin-left: 12%;
float: left;
display: none;
}
#values-button-small {
margin-top: 7%;
margin-left: 12%;
display: none;
}
<div class="wrapper">
<header>
<div id="logo">
<img src="resized-images-logo/logo-use.svg" alt="moby-dick-title" />
</div>
<!--end logo and title-->
<div id="hamburger-nav-large">
<a href="#mobile-footer-nav"><img src="icons-use/hamburger-menu-
large.png" alt="hamburger menu" /></a>
</div>
<!--end of hamburger-nav-large-->
<div id="hamburger-nav-small">
<a href="#mobile-footer-nav"><img src="icons-use/hamburger-menu-
small.png" alt="hamburger menu" /></a>
</div>
<!--end of hamburger-nav-small-->
<div id="hamburger-nav-tiny">
<a href="#mobile-footer-nav"><img src="icons-use/hamburger-menu-
tiny.png" alt="hamburger menu" /></a>
</div>
<!--end hamburger-nav-tiny-->
<div id="nav">
<ul>
<li>Whaling</li>
<li>Planning</li>
<li>About</li>
<li>Contact</li>
<li>Book Trip</li>
</ul>
</div>
<!--end of nav-->
</header>
<!--end of header-->
<main>
<div id="about-title">
<h2>About Us</h2>
</div>
<!--end of about-
title-->
<div id="left-column-background">
<div id="right-column-image"></div>
<!--end right-column-image-->
<div id="mission-button-large"><img src="resized-images-
logo/mission-button-large.svg" />
</div>
<!--end mission-button-large-->
<div id="mission-button-medium"><img src="resized-images-
logo/mission-button-medium.svg" />
</div>
<!--end mission-button-medium-->
<div id="mission-button-small"><img src="resized-images-
logo/mission-button-small.svg" />
</div>
<!--end mission-button-small-->
<div id="mission-text">We were established with one goal in mind, to provide the best whale watching experience to our customers. We are comprised of a team of passionate marine biologists eager to share our experiences and knowledge. </div>
<!--end mission-text-->
<div id="service-button-large"><img src="resized-images-
logo/service-button-large.svg" /></div>
<!--end service-button-large-->
<div id="service-button-medium"><img src="resized-images-
logo/service-button-medium.svg" /></div>
<!--end service-button-medium-->
<div id="service-button-small"><img src="resized-images-
logo/service-button-small.svg" /></div>
<!--end service-button-small-->
<div id="service-text">
Our service mantra is to give you the knowledge to truly enjoy the whale watching experience. Through reading material, video, live talks and demonstrations, we provide plenty of time to ask questions and explain what you are seeing.
</div>
<!--end service-text-->
<div id="values-button-large">
<img src="resized-images-logo/values-button-large.svg" />
</div>
<!--end values-button-large-->
<div id="values-button-medium">
<img src="resized-images-logo/values-button-medium.svg" />
</div>
<!--end values-button-medium-->
<div id="values-button-small">
<img src="resized-images-logo/values-button-small.svg" />
</div>
<!--end values-button-small-->
<div id="values-button-text">
All the folks at Moby-Dick Whaling Adventures are active environmentalists. We have experience documenting many of the challenges our planet faces. We feel that the best way to save our planet is to show it off.
</div>
<!--end values-button-text-->
</div>
<!--end left-column-background-->
<div class="clearfix"></div>
<!--end clearfix-->
</main>
<!--end of main-->
<div id="mobile-footer-nav">
<ul>
<li>Whaling</li>
<li>Planning</li>
<li>About</li>
<li>Contact</li>
<li>Book Trip</li>
</ul>
</div>
<!--end of mobile-footer-nav-->
<footer>
<div id="left-column-footer">
<p>Moby-Dick Whaling Adventures</p>
<table>
<tr>
<td><img src="icons-use/phone.svg" alt="phone-icon" /></td>
<td>888-888-8888</td>
</tr>
<tr>
<td><img src="icons-use/67-email.svg" alt="email-icon" />
</td>
<td>info#mobydick.com</td>
</tr>
</table>
<p>123 Whaling Ave<br/> Whaleport, MA 02934</p>
</div>
<!--end left-column-->
<div id="center-column-footer">
<p>Comprehensive, professional tours. Custom tailored to create maximum excitement.
</p>
</div>
<!--end of center-column-->
<div id="right-column-footer">
<div id="social-icons">
<img src="icons-use/instagram-white.svg" alt="instagram-icon" />
<img src="icons-use/06-facebook.svg" alt="facebook-icon" />
<img src="icons-use/twitter.svg" alt="twitter-icon" />
</div>
<!--end social-icons-->
<div id="small-social-icons">
<img src="icons-use/instagram-white-small.svg" alt="instagram-
icon" />
<img src="icons-use/06-facebook-small.svg" alt="facebook-
icon" />
<img src="icons-use/twitter-small.svg" alt="twitter-icon" />
</div>
<!--end small-social-icons-->
<div id="copyright-text">
<p>© 2017 Moby-Dick Whaling Adventures</p>
</div>
<!--end of copyright-text-icons-->
</div>
<!--end right-column-->
<div class="clearfix"></div>
</footer>
<!--end of footer text-->
</div>
<!--end of wrapper-->

Related

How to position (flush down) my footer with large screen size, when using Bootstrap 4?

I have problem with my footer. I am using ASP.NET Core 2 MVC, with Razor View.
Right now I tryed everything from this, including comments:
https://css-tricks.com/couple-takes-sticky-footer/ & https://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page
Note, that I do not want fixed footer. I know that there is several similar topics in SO, but I tryed already everything I found. I belive that I am missig something obvoius. I work on this whole day already and it just stops me.
Every time my footer is rendered just below Edit, Delete buttons, or somewhere in the middle of page. I am guessing that it might be something with my _Layout architecutre or for in Index file is causing ot somehow.
My _Layout.cshtml looks like this:
<div class="wrapper">
<div class="header">
<!--HEADER-->
</div>
<div class="content">
<!--BODY-->
#RenderBody()
</div>
<div class="footer">
<!--FOOTER-->
<footer>
<div></div>
</footer>
</div>
</div>
My Index.cshtml looks like (for most of the cases footer was rendered below Edit/Delete form:
<div>
#if (Context.User.Identity.IsAuthenticated)
{
<a asp-action="Create" class="btn btn-sm btn-primary adminBtn">Add new project</a>
}
<div>
#foreach (var item in Model)
{
<div class="projectContainer col-lg-6">
#if (Context.User.Identity.IsAuthenticated)
{
<form asp-action="Delete" method="post">
<a asp-action="Edit" class="btn btn-sm btn-warning"
asp-route-projectID="#item.ProjectID">
Edit
</a>
<input type="hidden" name="ProjectID" value="#item.ProjectID" />
<button type="submit" class="btn btn-danger btn-sm">
Delete
</button>
</form>
}
<div class="innerContainer" style="background-color: #item.BackColor">
<div class="projectHeader col-xs-12">
#item.Name
</div>
<div class="hyperButton col-xs-12">
<a asp-action="Details" asp-route-projectID="#item.ProjectID">See more ></a>
</div>
<div class="projectPictures col-xs-12">
<a asp-action="Details" asp-route-projectID="#item.ProjectID"><img src="#item.PictureUrl" asp-append-version="true" /></a>
</div>
</div>
</div>
}
</div>
</div>
My site.css looks like that right now:
html, body {
height: 100%;
overflow-x: hidden;
}
body {
min-height: 100%;
position: relative;
}
.footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
background-image: url(/src/img/footBG.png);
background-repeat: repeat;
border-top: 3px solid #557DA8;
height: 75px;
text-align: center;
}
.footText {
font-size: 20px;
position: relative;
top: 20px;
}
UPDATE with source code:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<link href="/src/lib/fontawesome/css/all.css" rel="stylesheet" />
<link rel="stylesheet" href="/src/lib/bootstrap/css/bootstrap.min.css">
<script src="/src/lib/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/dist/site.css" />
<style>
.input-validation-error {
border-color: red;
background-color: #fee;
}
</style>
<title>
Przemyslaw Bak - My projects
</title>
</head>
<body>
<div class="wrapper">
<div class="header">
<!--HEADER-->
<div class="mainHeader">
<div class="helloTextContainer col-12">
<div class="helloTxtWrapper">Hi! I am</div>
</div>
<div class="mainTextContainer col-sm-9 col-xs-12">
<div class="mainTxtWrapper">Przemyslaw Bak {developer}</div>
</div>
<div class="socialContainer col-sm-3 hidden-sm-down">
<!--VIEW COMPONENT-->
<i class="fab fa-facebook-square"></i>
<i class="fab fa-linkedin"></i>
<i class="fab fa-github-square"></i>
</div>
</div>
<div class="mainNavbar">
<div><a class="mainButton projects" href="/">my projects</a></div>
<div><a class="mainButton technologies" href="/MyTechnologies">technologies</a></div>
<div><a class="mainButton about" href="/Literature">literature</a></div>
<div><a class="mainButton contact" href="/ContactMe">about and contact</a></div>
</div>
<div class="stickyNavbar">
<div><a class="mainButton projects" href="/">my projects</a></div>
<div><a class="mainButton technologies" href="/MyTechnologies">technologies</a></div>
<div><a class="mainButton about" href="/Literature">literature</a></div>
<div><a class="mainButton contact" href="/ContactMe">about and contact</a></div>
</div>
<!--HERE TRIGGERS APP.JS-->
<div class="emptySpace" id="app"></div>
</div>
<!--BODY-->
<div class="content">
<!--button-->
<style>
.projects {
color: gray !important;
}
</style>
<div>
<div>
<div class="projectContainer col-lg-6">
<div class="innerContainer" style="background-color: #E8E8E8">
<div class="projectHeader col-xs-12">
Name of the project
</div>
<div class="hyperButton col-xs-12">
See more >
</div>
<div class="projectPictures col-xs-12">
<img src="#" />
</div>
</div>
</div>
<div class="projectContainer col-lg-6">
<div class="innerContainer" style="background-color: #fafafa">
<div class="projectHeader col-xs-12">
Name of the project
</div>
<div class="hyperButton col-xs-12">
See more >
</div>
<div class="projectPictures col-xs-12">
<img src="/src/img/website1.png?v=pdiYJ15drelz9-8uTNfrtUab7HjRkk9REgc4EOUOLHU" />
</div>
</div>
</div>
<div class="projectContainer col-lg-6">
<div class="innerContainer" style="background-color: #f9fbf8">
<div class="projectHeader col-xs-12">
Best project ever
</div>
<div class="hyperButton col-xs-12">
See more >
</div>
<div class="projectPictures col-xs-12">
<img src="/src/img/website1.png?v=pdiYJ15drelz9-8uTNfrtUab7HjRkk9REgc4EOUOLHU" />
</div>
</div>
</div>
</div>
</div>
</div>
<!--FOOTER-->
<div class="footer">
<footer>
<div class="footText">&copy 2018 - Przemyslaw Bak</div>
</footer>
</div>
</div>
<!--SCRIPTS-->
<script src="/dist/bundle.js"></script>
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
</body>
</html>
Currently after scrolling down my footer looks like this (2018 - Przemyslaw Bak):
UPDATE2:
I am using Bootstrap 4, maybe it changes something
Take out that position: absolute; in the footer CSS
.footer {
left: 0;
right: 0;
bottom: 0;
width: 100%;
background-image: url(/src/img/footBG.png);
background-repeat: repeat;
border-top: 3px solid #557DA8;
height: 75px;
text-align: center;
}
html, body {
height: 100%;
overflow-x: hidden;
}
body {
min-height: 100%;
position: relative;
}
.footer {
left: 0;
right: 0;
bottom: 0;
width: 100%;
background-image: url(/src/img/footBG.png);
background-repeat: repeat;
border-top: 3px solid #557DA8;
height: 75px;
text-align: center;
}
.footText {
font-size: 20px;
position: relative;
top: 20px;
}
<div class="wrapper">
<div class="header">
<!--HEADER-->
</div>
<div class="content">
<!--BODY-->
<p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p><p>#RenderBody()</p>
</div>
<div class="footer">
<!--FOOTER-->
<footer>
<div>Div inside footer</div>
</footer>
</div>
</div>
if you using bootstrap 4 there good solition for you,
https://getbootstrap.com/docs/4.0/utilities/flex/#align-self
you need self item end if you wanna use to bootstrap I think you should be use this.
After Viktor`s comments I stripped out my HTML code and started to suspect, that my Bootstrap (previously 4.0.6) is messing up something.
So I started to Google "flush footer bootstrap" and I found this:
Flush footer to the bottom of the page in bootstrap 4
After installation Bootstrap 4.1.X files, I changed my site.css and _Layout.cshtml as follows:
body, wrapper {
min-height: 100vh;
}
footer {
width: 100%;
background-image: url(/src/img/footBG.png);
background-repeat: repeat;
border-top: 3px solid #557DA8;
height: 75px;
text-align: center;
}
.footText {
font-size: 20px;
position: relative;
top: 20px;
}
_Layout.cshtml:
<body>
<wrapper class="d-flex flex-column">
//nav bar
//render body
<main class="container-fluid py-3 flex-fill">
#RenderBody()
</main>
//footer
<footer>
<div class="footText">&copy #DateTime.Now.Year - Przemyslaw Bak</div>
</footer>
</wrapper>
//scripts
</body>
And it works!

Keep text aligned top and image aligned to the bottom of relative height divs

I have 4 columns of products with a header, description and image below and I want the text areas to at the top and the images to each line up at the bottom so they stay aligned when the screen is resized.
At the moment the images move up and down as the text wraps - which looks very untidy as they each have a different amount of text.
I have tried using tables and position absolute and they each cause problems and don't work properly.
Here is my code:
#product-landing .landing-row {
position: relative;
height: inherit;
}
.product-landing,
.product-landing-2,
.product-landing-3 {
margin-right: 2.0533%;
}
.product-landing,
.product-landing-2,
.product-landing-3,
.product-landing-4 {
margin-left: 0px;
display: inline-block;
position: relative;
height: 100%;
vertical-align: top;
width: 22.978%;
}
.product-landing-4 {
margin-right: 0px;
}
#product-landing p {
margin-top: 0px;
margin-bottom: 5px;
clear: both;
width: 100%;
}
.product-landing .land-image {
vertical-align: bottom;
}
.product-landing img,
.product-landing-2 img,
.product-landing-3 img,
.product-landing-4 img {
margin-top: 10px;
display: block;
max-width: 350px;
margin: 0 auto;
bottom: 0px;
width: 100%;
}
<div id="product-landing">
<div class="landing-row">
<div class="product-landing">
<div id="product-text">
<div id="offer-title">Product1</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image1.jpg">
</p>
</div>
<div class="product-landing-2">
<div id="product-text">
<div id="offer-title">Product2</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image2.jpg">
</p>
</div>
<div class="product-landing-3">
<div id="product-text">
<div id="offer-title">Product3</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image3.jpg">
</p>
</div>
<div class="product-landing-4">
<div id="product-text">
<div id="offer-title">Product4</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image4.jpg">
</p>
</div>
</div>
</div>
You can use flexbox for this
#product-landing .landing-row {
display:flex;
flex-direction:row;
justify-content:space-between;
flex-wrap:wrap;
}
#product-landing p {
margin-top: 0px;
margin-bottom: 5px;
}
.product-landing {
display:flex;
flex-direction:column;
width: 22.978%;
}
.product-landing img {
margin-top: 10px;
display: block;
max-width: 350px;
width: 100%;
}
.product-text {
flex-grow:1;
}
<div id="product-landing">
<div class="landing-row">
<div class="product-landing">
<div class="product-text">
<div class="offer-title">Product1</div>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://via.placeholder.com/350x150">
</p>
</div>
<div class="product-landing">
<div class="product-text">
<div class="offer-title">Product2</div>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://via.placeholder.com/350x150">
</p>
</div>
<div class="product-landing">
<div class="product-text">
<div class="offer-title">Product2</div>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://via.placeholder.com/350x150">
</p>
</div>
<div class="product-landing">
<div class="product-text">
<div class="offer-title">Product3</div>
<p><b><i>Product description Product description Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://via.placeholder.com/350x150">
</p>
</div>
<div class="product-landing">
<div class="product-text">
<div class="offer-title">Product4</div>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://via.placeholder.com/350x150">
</p>
</div>
</div>
Would've commented this if I could; Have you tried using flex-box? https://css-tricks.com/snippets/css/a-guide-to-flexbox/
This has saved me on many occasions where relative/absolute combinations fail.
To be more specific;
.wrapper{
display:flex;
flex-direction:column;
}
.text-wrapper-div{
align-self:flex-start;
}
.image-wrapper-div{
align-self:flex-end;
}
.wrapper is your parent-container, which flexes from top to bottom (column).
Inside are the two div's for text and image, which align themselves to the top (flex-start) and bottom (flex-end).
Have a look at the link if you get stuck - it's pretty well documented I think! Good luck.
Hope this may help you,
Using flex is considered to be best practice. The table and table-cell are the old ways as we have came way far and new properties are being invented day by day. As using the flex will adjust the content itself as you resize the browser and has its own qualities.
#product-landing .landing-row {
display: flex;
flex-direction: row;
}
.product-landing,
.product-landing-2,
.product-landing-3 {
margin-right: 2.0533%;
}
.product-landing,
.product-landing-2,
.product-landing-3,
.product-landing-4 {
flex: 1;
text-align: center;
}
#product-landing p {
margin-top: 0px;
margin-bottom: 5px;
clear: both;
width: 100%;
}
.product-landing .land-image {
vertical-align: bottom;
}
.product-landing img,
.product-landing-2 img,
.product-landing-3 img,
.product-landing-4 img {
margin-top: 10px;
display: block;
max-width: 350px;
margin: 0 auto;
bottom: 0px;
width: 100%;
}
<div id="product-landing">
<div class="landing-row">
<div class="product-landing">
<div id="product-text">
<div id="offer-title">Product1</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image1.jpg">
</p>
</div>
<div class="product-landing-2">
<div id="product-text">
<div id="offer-title">Product2</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image2.jpg">
</p>
</div>
<div class="product-landing-3">
<div id="product-text">
<div id="offer-title">Product3</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image3.jpg">
</p>
</div>
<div class="product-landing-4">
<div id="product-text">
<div id="offer-title">Product4</div>
<p>
</p>
<p><b><i>Product description</i></b></p>
</div>
<p class="land-image">
<img src="http://image4.jpg">
</p>
</div>
</div>
</div>

stop `inline-block` and then start again

On a page of mine I have two elements (let's name them X and Z) styled with inline-block, so they are positioned one next to the other.
Right below them I want to place three elements (let's name them A,B,C), one next to the other again.
When I insert element A with inline-block, it goes next to Z.
If I apply clear:both to A, then it goes under (so that's good) but if I also apply inline-block to A, then A, B and C go right next to X and Z! How can I override this?
.header h1 {
text-align: center;
}
.map img{
width: 100%;
height: 100%;
}
.logo {
display: inline-block;
float: left;
}
.logo img {
display: block;
margin: auto;
}
.info {
padding: 5px ;
display: inline-block;
float: left;
background-color: #c0dfd9
}
.column1 {
width: 45%;
}
<div class="container" id="contact"> <!-- /CONTACT -->
<div class="map">
<img src="img/map.jpg" alt="map">
</div>
<div class="header">
<h1 id="contactheader">Contact me</h1>
<div>
<div class="logo column1">
<img src="img/logo.png" alt="logo">
</div>
<div class="info column1">
<p><span class="glyphicon glyphicon-user"></span><strong>Email:</strong>John#john.com</p>
<p><span class="glyphicon glyphicon-home"></span><strong>Address:</strong>Plateia Karitsi 25</p>
<p><span class="glyphicon glyphicon-asterisk"></span><strong>Telephone:</strong>+30 1654984</p>
</div>
</div> <!-- /END CONTACT -->
<br>
<footer>
<div id="copyright">©John 2016</div>
<div id="twitterbutton">Follow #aptbs</div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<div class="fb-like" data-href="https://www.facebook.com/QOTSA/?fref=ts" data-layout="button" data-action="like" data-show-faces="true" data-share="false"></div>
</footer>
Line break: https://developer.mozilla.org/en/docs/Web/HTML/Element/br
div {display: inline-block; padding: 8px 12px; background: #ccc; margin: 4px}
<div>x</div>
<div>z</div>
<br>
<div>a</div>
<div>b</div>
<div>c</div>
No need to complicate simple things.
Here's your code modified by what I wrote in the comment:
You need to remove float rules from X and Z. And then you won't even need the <br> because they're in separate blocks. Also, make sure A, B and C are inline-blocks as well (they are blocks now).
.header h1 {text-align: center;}
.map img{width: 100%; height: 100%;}
.logo, #twitterbutton, #copyright, .fb-like {display: inline-block;}
.logo img {display: block; margin: auto;}
.info {padding: 5px; display: inline-block; background-color: #c0dfd9}
.column1 {width: 45%;}
<div class="container" id="contact"> <!-- /CONTACT -->
<div class="map">
<img src="img/map.jpg" alt="map">
</div>
<div class="header">
<h1 id="contactheader">Contact me</h1>
<div>
<div class="logo column1">
<img src="img/logo.png" alt="logo">
</div>
<div class="info column1">
<p><span class="glyphicon glyphicon-user"></span><strong>Email:</strong>John#john.com</p>
<p><span class="glyphicon glyphicon-home"></span><strong>Address:</strong>Plateia Karitsi 25</p>
<p><span class="glyphicon glyphicon-asterisk"></span><strong>Telephone:</strong>+30 1654984</p>
</div>
</div> <!-- /END CONTACT -->
<footer>
<div id="copyright">©John 2016</div>
<div id="twitterbutton">Follow #aptbs</div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<div class="fb-like" data-href="https://www.facebook.com/QOTSA/?fref=ts" data-layout="button" data-action="like" data-show-faces="true" data-share="false"></div>
</footer>

Change content on hovering, only by CSS

I have seen many different ways to resolve the following, but it does not work quite as I hoped...
I need to make a div (main div) with severel divs inside (item-divs).
Each item-div must show a different picture, but when I hover a certain picture, this picture should be hidden and a text showen instead - in the same div.
How on earth can I make this?
For example this variant:
<div class="wrap">
<div class="child1"></div>
<div class="child2"></div>
</div>
And your css chould be:
.wrap:hover > child2{
opacity: 0;
}
But static styles should be like this:
.wrap{
width: 200px;
height: 300px; /* maybe auto if you want */
position: relative;
}
.child1{
width: 100%;
height: 100%;
background: lightgreen;
}
.child2{
width: 100%;
height: 100%;
background: #ff3030; /* surely for example */
position: absolute;
top: 0;
left: 0;
}
/* and this block .child2 will be faced. When it's opacity will be 0, you get your effect */
You can do this with the CSS pseudo element :hover
See example:
http://jsbin.com/vijawuda/1/edit?html,css,output
HTML Markup:
<div class='outer-container'>
<div class='image-holder'>
<img src='' />
<div class='text'>
Test image 1
</div>
</div>
<div class='image-holder'>
<img src='' />
<div class='text'>
Test image 2
</div>
</div>
<div class='image-holder'>
<img src='' />
<div class='text'>
Test image 3
</div>
</div>
<div class='image-holder'>
<img src='' />
<div class='text'>
Test image 4
</div>
</div>
<div class='image-holder'>
<img src='' />
<div class='text'>
Test image 5
</div>
</div>
</div>
CSS
.image-holder {
width: 150px;
height: 150px;
display: inline-block;
}
.image-holder > .text {
visibility: hidden;
width: 150px;
height: 150px;
}
.image-holder:hover img {
visibility: hidden;
}
.image-holder:hover .text {
visibility: visible;
}
HTML
<div class="main">
<div class="content">
<div class="maincontent">
<img src="http://lorempixel.com/150/150/" alt="" height="150" width="150" />
</div>
<div>Hovering Content</div>
</div>
<div class="content">
<div class="maincontent">
<img src="http://lorempixel.com/150/150/" alt="" height="150" width="150" />
</div>
<div>Hovering Content</div>
</div>
<div class="content">
<div class="maincontent">
<img src="http://lorempixel.com/150/150/" alt="" height="150" width="150" />
</div>
<div>Hovering Content</div>
</div>
<div class="content">
<div class="maincontent">
<img src="http://lorempixel.com/150/150/" alt="" height="150" width="150" />
</div>
<div>Hovering Content</div>
</div>
<div class="content">
<div class="maincontent">
<img src="http://lorempixel.com/150/150/" alt="" height="150" width="150" />
</div>
<div>Hovering Content</div>
</div>
</div>
CSS
.main {
width: 1000px;
height: 200px;
}
.content {
width: 150px;
height: 150px;
background-color:#c80000;
color:#fff;
font-family:arial;
text-align:center;
float:left;
margin-left: 10px;
font-size: 20px;
cursor:pointer;
}
.content > div.maincontent + div {
display:none;
padding-top:50px;
}
.content:hover > div.maincontent {
display:none;
}
.content:hover > div.maincontent + div {
display:block;
}
http://jsfiddle.net/q92zL/4/

Center images within div

Hello guys I'm trying to centre some images. They keep on floating to the left,I've tried text-aligning but it doesn't seem to work. THe jsfiddle is here. http://jsfiddle.net/E7Ydz/2/ P.S. I could probably do this when I've had some sleep, it's 5:56 in London :(
[HTML]
<div id="portfolio" style="height: 3020px;">
<div id="project" class="cms design html-css " data-col="1" data-row="0" style="right: 0px; opacity: 1; top: 0px;">
<div id="workEntry1" class="workEntry">
<div id="thumbAttachment">
<div id="inThumb">
<img src="http://www.enjoythis.co.uk/wp-content/files_mf/work_thumbnail275.jpg">
</div>
<div id="blackCross"> <img src="http://www.enjoythis.co.uk/wp-content/themes/enjoyThis/images/thumb_transparency.png"></div>
</div>
<!--<div id="attachmentShadowThumb"></div>-->
<div id="workTitle">
</div>
<div id="workTags">
</div>
</div>
</div>
<div id="project" class="design illustration html-css " data-col="2" data-row="0" style="right: 0px; opacity: 1; top: 0px;">
<div id="workEntry2" class="workEntry">
<div id="thumbAttachment">
<div id="inThumb">
<img src="http://www.enjoythis.co.uk/wp-content/files_mf/work_thumbnail2.jpg">
</div>
<div id="blackCross"> <img src="http://www.enjoythis.co.uk/wp-content/themes/enjoyThis/images/thumb_transparency.png"></div>
</div>
<!--<div id="attachmentShadowThumb"></div>-->
<div id="workTitle">
</div>
<div id="workTags">
</div>
</div>
</div>
<div id="project" class="app database design " data-col="0" data-row="1" style="right: 0px; opacity: 1; top: 0px;">
<div id="workEntry3" class="workEntry">
<div id="thumbAttachment">
<div id="inThumb">
<img src="http://www.enjoythis.co.uk/wp-content/files_mf/pgtips_thumb37.jpg">
</div>
<div id="blackCross"> <img src="http://www.enjoythis.co.uk/wp-content/themes/enjoyThis/images/thumb_transparency.png"></div>
</div>
<!--<div id="attachmentShadowThumb"></div>-->
<div id="workTitle">
</div>
<div id="workTags">
</div>
</div>
</div>
[css]
#project{
float:left;
position:relative;
padding: 0px 0px 0px 2px;
height:200px;
width:309px;
display: inline;
}
.workEntry{
width:310px;
overflow:hidden;
}
#thumbAttachment{
float:left;
width: 310px;
height:200px;
overflow: hidden;
}
#inThumb{
float:left;
}
#blackCross{
float:left;
width: 310px;
height:200px;
margin-top:-200px;
khtml-opacity:0;
-moz-opacity:0;
-ms-filter:"alpha(opacity=0)";
filter:alpha(opacity=0);
opacity:0;
}
#blackCross:visited{
khtml-opacity:0;
-moz-opacity:0;
-ms-filter:"alpha(opacity=0)";
filter:alpha(opacity=0);
opacity:0;
}
#blackCross:hover{
khtml-opacity:1;
-moz-opacity:1;
-ms-filter:"alpha(opacity=100)";
filter:alpha(opacity=100);
opacity:100;
}
Hope I understand your question well. You should use margin-left: auto; and margin-right: auto; to make a div (or in a better word, a block position element) center.
For instance you should change your css code to something like:
#inThumb{
margin-left: auto;
margin-right: auto;
}
See this jsFiddle: http://jsfiddle.net/E7Ydz/4/

Resources