How to center content in footer - html

I am building a website using wordpress theme. I have two elements (one floated left, second floated right) in the footer. I need to make it centered (the second one below the first one) when I resize the browser window. I tried giving the <p> and <div> tag a class and then style it to float:none; - hovewer you cann check that It didn't really work on the webpage. I also attach a picture of how I want it to be..
WEBPAGE
<div class="site-info">
<div style="margin:0 auto; width: 75%;">
<p style="float:left;">© Copyright <?= date('Y'); ?> Hotel Švýcarský Dům</p>
<div style="float:right;">Naleznete nás na sociálních sítích:
<a style="display: block; float:right; margin:-4px 0 0 5px;" href=""><img src="/wp-content/themes/adamos/images/gplus.png" /></a>
<a style="display: block; float:right; margin:-4px 5px 0 5px;" href=""><img src="/wp-content/themes/adamos/images/facebook.png" /></a>
</div>
<div class="clear"></div>
</div>
</div><!-- .site-info -->

Here is updated code. with a screen less than 600px, the divs will go on top of each other. This probably will need tweaking to fit on your site.
#left {
float: left;
}
#right {
float: right;
}
#center {
text-align: center;
}
#container {
margin-left: 12.5%;
margin-right: 12.5%;
}
.imagefloat {
display: block;
float: right;
margin: -4px 5px 0 5px;
}
#media (max-width: 600px) {
.nofloat {
width: 100%!important;
text-align: center;
float: none!important;
}
.imagefloat {
float: none!important;
}
}
<div class="site-info">
<div id="container">
<div id="left" class="nofloat">© Copyright
<?=d ate( 'Y'); ?>Hotel Švýcarský Dům</div>
<div id="right" class="nofloat">
<a class="imagefloat" href="">
<img src="/wp-content/themes/adamos/images/gplus.png" />
</a>
<a class="imagefloat" href="">
<img src="/wp-content/themes/adamos/images/facebook.png" />
</a>
</div>
<div id="center">Naleznete nás na sociálních sítích:</div>
<div class="clear"></div>
</div>
</div>

Perhaps add align-text:center to one of the divs and a p tag to put the images on a new line
<div class="site-info">
<div style="text-align:center; width: 75%;">
<p >© Copyright <?= date('Y'); ?> Hotel Švýcarský Dům</p>
<div >Naleznete nás na sociálních sítích:
<p><img src="/wp-content/themes/adamos/images/gplus.png" />
<img src="/wp-content/themes/adamos/images/facebook.png" />
</div>
<div class="clear"></div>
</div>
</div>

Firstly, you kept your float:left and float:right as inline styling so you will need to move the left and right float to an external css as you can't override inline styling with just css.
Secondly, Add a separate class for the left and right, say class="float-left" and class="float-right" and then use media query to switch properties for the classes like this:
#media (max-width: 768px) {
.float-left {
float: none;
}
.float-right {
float: none;
}
}
#media (min-width: 769px) {
.float-left {
float: left;
}
.float-right {
float: right;
}
}
Thirdly, to center the footer text on smaller screens, just add text-align: center to the above media query like this:
#media (max-width: 768px) {
.site-info {
text-align: center;
}
.float-left {
float: none;
}
.float-right {
float: none;
}
}
Lastly, add the icons and text within a <p></p> tag so they will line-break accordingly.

Related

How do I conditionally align elements based on screen size?

I have a fairly simple header on my site:
<header>
<nav class="navbar navbar-inverse" style="">
<div class="navContainer">
<div id="navbar">
<div id="leftNavSection">
<img alt="My Logo" width="300" src="/assets/main_logo-791a416e4f99d38a339debb8dcebd7361d4172919425ace42ba2ce90336218e2.png">
</div>
<div id="rightNavSection">
Logged in as Dave A
Edit
<a rel="nofollow" data-method="delete" href="/logout">Log Out</a>
</div>
</div>
</div>
</nav>
</header>
I align the logo to the left and the Logout links to the right:
#leftNavSection {
float: left;
}
#rightNavSection {
float: right;
}
What I would like, however, is if the screen size is small (mobile browsers), for the Log Out links to appear aligned to the left beneath the logo.
However, when I change the “float:right” to “float:left” this doesn’t happen. Here is my Fiddle — https://jsfiddle.net/kje3q74k/. How do I pull this off?
So here's one way to do it:
Add min-width: 50% to the leftNavSection and rightNavSection.
This allows the rightNavSection to wrap to the second line on
smaller displays when the content widths forces it down.
Remove the default margin of body using to adjust for the 100% width of the navbar:
body {
margin: 0;
}
Now the wrapping will occur exactly below 600px!
Float the rightNavSection to the left and align it to the right using text-align: right
Below 600px use text-align: left using media query:
#media only screen and (max-width: 600px) {
#rightNavSection {
text-align: left;
}
}
snippet below:
body {
margin: 0;
}
header {
overflow: hidden;
}
#navbar {
width: 100%;
font-family: Arial;
vertical-align: top;
display: inline-block;
}
#leftNavSection {
float: left;
min-width: 50%;
}
#rightNavSection {
float: left;
min-width: 50%;
text-align: right;
}
#media only screen and (max-width: 600px) {
#rightNavSection {
text-align: left;
}
}
<header>
<nav class="navbar navbar-inverse" style="">
<div class="navContainer">
<div id="navbar">
<div id="leftNavSection">
<img alt="My Logo" width="300" src="http://placehold.it/300x300">
</div>
<div id="rightNavSection">
Logged in as Dave A
Edit
<a rel="nofollow" data-method="delete" href="/logout">Log Out</a>
</div>
</div>
</div>
</nav>
</header>
Hope you can take it forward from the above example. Let me know your feedback on this. Thanks!

image size using different media queries

I have the following problem. I have a block split in two div's left and right, the left contain image with 640x461 and the right one split also in two div's
one contains text and beneath it an image 640x342. on the mobile site these are underneath each other image(640x461),text block then image(640x342), but given different screen size using media e.g #media (min-device-width: 568px) the right div(text+img) should float next to left div, but the problem is that the height of my left image still smaller than the height of right div. What should i do here?
HTML:
<div class="block_acc">
<div class="lp-bild-left">
<a>
<img src="640x461.jpg" />
</a>
</div>
<div class="lp_column">
<div class="lp_description">
<div class="lp_textbox_wrapper">
<span class="headline">text</span>
</div>
</div>
<div class="lp-bild-right">
<img src="640x342.jpg" />
</div>
</div>
</div>
CSS:
#media (min-device-width: 568px) {
.lp-bild-left{
float: left;
width: 50%;
}
.lp_column {
float: left;
width: 50%;
}
}
OK, check this code:
<div class="block_acc">
<div class="lp-bild-left">
<a href="#">
<img src="http://planeon.net/wp-content/uploads/hot-air-balloon.jpg" />
</a>
</div>
<div class="lp_column">
<div class="lp_description">
<div class="lp_textbox_wrapper">
<span class="headline">text</span>
</div>
</div>
<div class="lp-bild-right">
<img src="http://www.whudat.de/images/Albuquerque-Balloon-Fiesta_4.jpg" />
</div>
</div>
</div>
CSS...
.block_acc {
display: block;
overflow: hidden;
}
#media (min-device-width: 568px) {
.lp-bild-left {
float: left;
width: 50%;
}
.lp-bild-left img {
height: auto;
width: 100%;
}
.lp_column {
float: left;
width: 50%;
}
.lp_column .lp-bild-right {
max-width: 100%;
}
.lp_column .lp_textbox_wrapper {
line-height: 0;
}
.lp_column .lp_textbox_wrapper .headline {
font-size: 1vw;
line-height: normal;
}
.lp_column .lp-bild-right img {
width: 130%;
}
}
https://fiddle.jshell.net/jonathanzuniga/at57emmd/

Float right div over left div

As you can see bottom I've two div inline/columbs (one-half - left of page, one half last - right of page). My goal is to float the 2° div (one half last) over the first when the page is resized.
Basically I want that the 1° div collapse under the 2°. Is there a way to do this?
The trouble is that I can only obtain the float left of 2° div under the 1°.
Advices?
<div>
<div class="one-half">
<h2>Title</h2>
<p style="text-align: justify;">Text</p>
<p style="text-align: justify;">Text.</p>
<p style="text-align: justify;">Text.</p>
</div>
<div class="one-half last">
<img src="#" class="shadow" alt="#" style="max-width: 455px;width: 100%;">
</div>
<div class="clearfix"></div>
</div>
.one-half {
width: 460px;
}
.last {
float: left;
}
Pure css and html way : for page resize detection, use media queries
#media screen and (max-device-width: 600px) {
.one-half {
display: none;
}
.last {
float: left;
}
}
EDIT
considering the comment, update css to
#media screen and (max-device-width: 600px) {
.one-half {
float:left;
}
.last {
float: left;
clear: left;
}
}

Twitter Bootstrap breaking contents of div with several elements inside

I am using bootstrap to develop a responsive site.
I have two containers that have content which I don't want to break onto new lines if the window is resized.
I currently have this fiddle which demonstrates.
I thought using clearfix on the parent container for each news item would work. But the text is breaking from the image on resize.
You can see this in this image
Any clues?
This is the basic css (although it's all in the fiddle):
/* News items */
.news-item {
padding:10px 0 10px 10px;
}
.news-item p {
padding:0;
margin:0;
}
.news-item img,
.news-item-text {
float:left;
}
.news-item-text {
padding:0 0 0 5px;
}
.news-heading {
font-size:18px;
}
.news-tags {
font-family:ffs-italic;
font-size:12px;
}
This is the top of the html:
<div class="row"><!-- breaking and buzzing -->
<div class="span4"><!-- breaking news -->
<h2>Breaking</h2>
<div id="breakingNews" class="rounded clearfix">
<div class="news-item clearfix">
<a href="">
<img src="img/news/sm/sq01.jpg" width="54" height="54" />
</a>
<div class="news-item-text">
<p class="news-heading">Omni Scents to launch...</p>
<p class="news-subheading">At vero eos fragrance line inspired</p>
<p class="news-tags">BEAUTY, PRODUCTS</p>
</div>
</div>
<div class="news-item clearfix">
<a href="">
<img src="img/news/sm/sq02.jpg" width="54" height="54" />
</a>
<div class="news-item-text">
<p class="news-heading">IFF finishes year strong...</p>
<p class="news-subheading">Lorem ipsum in dolor contratis</p>
<p class="news-tags">INDUSTRY</p>
</div>
</div>
You in those cases you need to float your divs and also specify a width for the div, like this:
.news-item {
padding: 10px 0 10px 10px;
float: left;
width: 220px;
}
Also you need to determine the width of each <p>inside the divs, like this:
.news-item-text {
padding: 0 0 0 5px;
width: 160px;
}
For responsive layout, you need to use the tag #mediato set each width again, like:
#media (max-width: 767px) {
.news-item {
padding: 10px 0 10px 10px;
float: left;
width: 160px;
}
.news-item-text {
padding: 0 0 0 5px;
width: 100px;
}
}
I hope it works!
.news-item a
{
display: block;
float: left
}
.news-item-text
{
float: right;
width: 75%; /* adjust this to fit */
}

CSS content overflowing containing div

Currently have a problem with some DIVs overlapping their containing DIVs. See image below (the 3 products at the bottom):
All the body content of the page is held within the #content DIV:
div#content {
width: 960px;
float: left;
background-image: url("../img/contentBg.png");
background-repeat: repeat;
margin-top: 10px;
line-height: 1.8em;
border-top: 8px solid #5E88A2;
padding: 10px 15px 10px 15px;
}
And here is the CSS for the product boxes within the #content div:
.upper {
text-transform: uppercase;
}
.center {
text-align: center;
}
div#products {
float: left;
width: 100%;
margin-bottom: 25px;
}
div.productContainer {
float: left;
width: 265px;
font-size: 1em;
margin-left: 50px;
height: 200px;
padding-top: 25px;
text-align: right;
}
div.product {
float: left;
width: 200px;
}
div.product p {
}
div.product a {
display: block;
}
div.product img {
float: left;
}
div.product img:hover {
opacity: 0.8;
filter: alpha(opacity = 80);
}
div.transparent {
opacity: 0.8;
filter: alpha(opacity = 80);
}
And here is the HTML for the boxes:
<div class="productContainer">
<div class="product">
<h2 class="upper center">A2 Print</h2>
<a href='../edit/?productId=5&align=v' class='upper'> <img src="../../wflow/tmp/133703b808c91b8ec7e7c7cdf19320b7A2-Print.png" alt="Representation of image printed at A2 Print through Website." /></a>
<p class="upper">16.5 inches x 23.4 inches<br /><strong>£15.99</strong></p>
<p class="upper smaller"><em><span><span class="yes">Yes</span> - your picture quality is high enough for this size</span> </em></p>
<p><a href='../edit/?productId=5&align=v' class='upper'><span>Select</span></a></p>
</div>
</div>
<div class="productContainer">
<div class="product transparent">
<h2 class="upper center">A1 Print</h2>
<a href='../edit/?productId=11&align=v' class='upper'> <img src="../../wflow/tmp/133703b808c91b8ec7e7c7cdf19320b7A1-Print.png" alt="Representation of image printed at A1 Print through Website." /></a>
<p class="upper">23.4 inches x 33.1 inches<br /><strong>£19.99</strong></p>
<p class="upper smaller"><em><span><span class="no">Warning</span> - your picture quality may not be sufficient for this size</span> </em></p>
<p><a href='../edit/?productId=11&align=v' class='upper'><span>Select</span></a></p>
</div>
</div>
<div class="productContainer">
<div class="product transparent">
<h2 class="upper center">Poster Print (60cm x 80cm)</h2>
<a href='../edit/?productId=12&align=v' class='upper'> <img src="../../wflow/tmp/133703b808c91b8ec7e7c7cdf19320b7Poster-Print-(60cm-x-80cm).png" alt="Representation of image printed at Poster Print (60cm x 80cm) through Website." /></a>
<p class="upper">23.6 inches x 31.5 inches<br /><strong>£13.95</strong></p>
<p class="upper smaller"><em><span><span class="no">Warning</span> - your picture quality may not be sufficient for this size</span> </em></p>
<p><a href='../edit/?productId=12&align=v' class='upper'><span>Select</span></a></p>
</div>
</div>
Any idea what could be causing these DIVs to overlap? What I'd like is for all the boxes to fit within the #container div as expected. It's driving me crazy!
Cheers
Did you try to set to the footer
clear:both;
Also, set to the #content
overflow:hidden;
Add overflow: auto; in your content div CSS :)
Something a lot of people use is called clearfix. here is the code:
.clearfix:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
.clearfix {display:inline-block;}
/* Hide from IE Mac \*/
.clearfix {display:block;}
/* End hide from IE Mac */
To use this you just add the class clearfix to container. You will probably want to add it to whatever div is containing all the "productContainer"