Div align to center - html

Hello i spent hours doing this but still can't align the social media icons to the center of text "Connect with us" when it's in desktop size. It's only aligned when it's in mobile size i want them to align to center either its desktop size or mobile. I want the content of the footer to be responsive. I already used media queries but i encounter a problem so i repeat my footer again from the start because its not responsive when in desktop size. Please give me some ideas how to do it or suggestions. Im new to html and css.
here is the desktop size. I want the social media icons to align to the center of text "Connect with us".
here is the mobile size. Its well aligned here.
UPDATE:
This is what i want to do in the first picture. But i repeat my footer because when i minimized it as a desktop its not responsive the alignments, the text, the height it's a disaster so i decided to do it again from the start. I already used media queries before but as a desktop its not working when i minimized it it's not responsive but in mobile size its working.
here is my html code for the footer.
<div class="content">
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4">
<h4 class="connect">Connect With Us</h4>
<div class="twitter-hover social-slide"></div>
<div class="facebook-hover social-slide"></div>
<div class="linkedin-hover social-slide"></div>
</div>
</div>
</div>
</div>
</footer>
here is my css code.
* {
margin: 0;
}
html, body {
height: 100%;
overflow: auto;
}
.content {
min-height: 100%;
/* equal to footer height */
margin-bottom: auto;
}
.content:after {
content: "";
display: block;
}
.footer, .content:after {
height: auto;
}
.footer {
display: block;
background-color: #a92419;
color:#fff;
font-family: Century Gothic;
width: 100%;
height: auto;
}
h4{
text-align: center;
padding-top: 20px;
}
.twitter-hover {
background-image: url('images/twitter-hover.png');
margin-left: 65px;
}
.facebook-hover {
background-image: url('images/facebook-hover.png');
margin-left: 15px;
}
.linkedin-hover {
background-image: url('images/linkedin-hover.png');
margin-left: 15px;
}
.social-slide:hover {
background-position: 0px -48px;
box-shadow: 0px 0px 4px 1px rgba(0,0,0,0.8);
}
.social-slide{
height: 35px;
width: 38px;
float:left;
-webkit-transition: all ease 0.3s;
-moz-transition: all ease 0.3s;
-o-transition: all ease 0.3s;
-ms-transition: all ease 0.3s;
transition: all ease 0.3s;
}

Update: rewritten my answer completely.
You shouldn't use float:left when you want your content to be centered.
<div class="footer-col col-sm-4">
<h4 class="connect">Connect With Us</h4>
<ul>
<li><span class="twitter-hover social-slide"></span></li>
<li><span class="facebook-hover social-slide"></span></li>
<li><span class="linkedin-hover social-slide"></span></li>
</ul>
</div>
css:
.footer-col h4 {
text-align: center;
}
.footer-col ul {
list-style: none;
text-align: center;
}
.footer-col li {
display: inline;
}
.social-slide {
display: inline-block;
height: 35px;
width: 38px;
line-height: 35px;
margin-left: 15px;
/* don't use float: left! */
}
.social-slide:first-child {
margin-left: 0;
}
.twitter-hover { background-image: url('images/twitter-hover.png'); }
.facebook-hover { background-image: url('images/facebook-hover.png'); }
.linkedin-hover { background-image: url('images/linkedin-hover.png'); }

if you also use bootstrap latest then you use this class
col-sm-offset-......12
you don't know what size of your device you adjust self` col-sm-offset........12345 up to12
for more detail read out
https://getbootstrap.com/examples/grid/

Here is the fiddle
https://jsfiddle.net/brunocoder/ozgntcm2/1/
First of all there is one extra closing div in your footer tag.
You need to use bootstrap offset property to centralize your column. Here is the link http://getbootstrap.com/css/#grid
So your code should be something like this.
Modified HTML
<div class="content">
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4">
<h4 class="connect">Connect With Us</h4>
<div class="twitter-hover social-slide"></div>
<div class="facebook-hover social-slide"></div>
<div class="linkedin-hover social-slide"></div>
</div>
</div>
</div>
</footer>

Use bootstrap in every section of your code, like if you have used div inside the div , use bootstrap to align them also as if you not then it will not align themselves according to the screen size.
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4">
<h4 class="connect">Connect With Us</h4>
<a href="https://twitter.com/official_gapc" target="_blank" title="Follow us on Twitter">
<div class="twitter-hover social-slide col-sm-4">
</div>
</a>
<a href="https://www.facebook.com/pages/Governor-Andres-Pascual-CollegeNavotas-City/344134628983014?fref=ts" target="_blank" title="Like us on Facebook">
<div class="facebook-hover social-slide col-sm-4">
</div>
</a>
<a href="https://www.linkedin.com/edu/governor-andres-pascual-college-in-navotas-city-39345" target="_blank" title="Join us on Linkedin">
<div class="linkedin-hover social-slide col-sm-4">
</div>
</a>
</div>
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4"></div>
<div class="footer-col col-sm-4 col-md-4 col-lg-4 col-md-offset-4"></div>
</div>
</div>
</footer>
place anything you want to place in two div below or remain as it is, might it will help you to make responsive footer.

Related

Bootstrap Layout center container

I am new to bootstrap and am trying to create the following layout without success.
<div class="container-fluid">
<!-- Logo row -->
<div class="row">
<div class="col-sm-12">
<div class="header">
<img id="logoImage" src="#" height="67px">
</div>
</div>
</div>
<!-- QRCODE row-->
<div class="row gradient qrCodeRow ">
<div class="row" style="height: 100px;"></div>
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="qrCode"><img src="#" height="300px" width="300px"></div>
</div>
<div class="col-xs-12 col-sm-12 col-md-6">
<div class="text qrText ">
<p class="bigText"><strong>text</strong> text</p>
<p>text</p>
<p>text</p>
</div>
</div>
</div>
</div>
and css:
.container-fluid {
padding: 0;
margin: 0;
}
.v-center {
position: relative;
transform: translateY(50%);
}
.gradient {
background: #1a5062; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(#1a5062, #0d2933); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#1a5062, #0d2933); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#1a5062, #0d2933); /* For Firefox 3.6 to 15 */
background: linear-gradient(#1a5062, #0d2933); /* Standard syntax */
}
.text {
color: #ffffff;
font-family: sans-serif;
}
/* header */
.header {
height: 121px;
padding: 0px 36px 0px 36px;
display: flex;
align-items: center;
}
/* qrcode */
.qrCodeRow {
min-height:502px;
}
.qrCode {
float: right;
}
.qrCode img {
height: 300px;
width: 300px;;
}
.qrText {
height: 300px;
padding-left: 45px;
font-size: 24pt;
font-family: "DIN Neuzeit Grotesk Std Light";
}
I can not figure out how to make the middle part stay 1200px all the time until it has to resize. And I haven't even started thinking of how to make M1 go on top of M2.
I believe this is what you are looking for. First I created a header that is empty and fullwidth. Next I created the main element with the container (of 1200px) in it. The container has a negative margin-top to pull it up. Inside this container you can find the 2 columns. Adding col-xs-12 will make the column 100% width on xs-devices (extra small devices eq phones) and col-md-4 will make this column only 4/12th width of the container on medium devices (desktop) adding these 2 classes together with some offset for the columns makes it responsive. Below you can see the code created in this bootply: http://www.bootply.com/04pBMcDCSu
<div class="wrapper" style="background-color: red;">
<header style="height: 300px; background-color: white;">
</header>
<main>
<!-- (1) -->
<div class="container" style="margin-top: -100px; background-color: yellow;">
<div class="row">
<div class="col-xs-12 col-md-4 col-md-offset-1" style="background-color: blue; height: 300px;">
<h1>M1</h2>
</div>
<div class="col-xs-12 col-md-4 col-md-offset-2" style="background-color: green; height: 300px;">
<h1>M2</h2>
</div>
</div>
</div>
<!-- (2) -->
</main>
</div>

Bootstrap navbar how can i underline with a line with spaces in both sides?

I'm trying to make a menu with bootstrap 3, I'm actually using code like this:
<section id="menu">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-2">
<img class="img-responsive" src="logo.jpg" alt="logo">
</div>
<div class="col-xs-12 col-sm-2 nana">
<p>Some other menu</p>
</div>
<div class="col-xs-12 col-sm-2">
<p>Some other menu</p>
</div>
<div class="col-xs-12 col-sm-2">
<p>Some other menu</p>
</div>
<div class="col-xs-12 col-sm-2">
<p>Some other menu</p>
</div>
<div class="col-xs-12 col-sm-2">
<p>Some other menu</p>
</div>
</div>
</div>
</section>
But I want to achieve this:
how can i put the lines , I use "border-bottom" property but it expands all the column, I just want to have the separations of each menu, if I apply margins it just broke the menu.
Is there a way to achieve this?
I'm thinking of using :before, :after,
But I don't know, anybody can help me!
You can use css ::after Selector for creating this type of thing.
.col-sm-2::after {
content: "";
position: absolute;
width: 90%;
height: 3px;
left: 0;
right: 0;
margin: auto;
background: #aaa;
transition: all .35s;
}
.col-sm-2:hover::after {
background: #68c122;
}
Here is a small fiddle to get started.
But I strongly suggest Using <nav class="navbar" role="navigation"></nav>
for a creating navigation.
Try playing with :hover pseudo class
ul li {
display: inline;
text-align: center;
}
a {
display: inline-block;
width: 25%;
padding: .75rem 0;
margin: 0;
text-decoration: none;
color: #333;
}
.two:hover ~ hr {
margin-left: 25%;
}
.three:hover ~ hr {
margin-left: 50%;
}
.four:hover ~ hr {
margin-left: 75%;
}
hr {
height: .25rem;
width: 25%;
margin: 0;
background: green;
border: none;
transition: .3s ease-in-out;
}
<div class="container">
<ul>
<li class="one">Menu Text</li><!--
--><li class="two">Menu Text</li><!--
--><li class="three">Menu Text</li><!--
--><li class="four">Menu Text</li>
<hr />
</ul>
</div>
Simple Just add
margin-left: 2px;
margin-right: 2px; // change the values based on your requirement
for the menu items (in your case it will be the div to which you are adding border-bottom).
USE NAVBAR
But looking at your code I would like to suggest you to build your menu the correct way using bootstraps navbar component.
Read more about it here:
https://getbootstrap.com/components/#navbar

Structuring thumbnails on bootstrap

So I have this issue with positioning and aligning thumbnails. I want to put fixed width and height on a div but as I am using Bootstrap, I've put col-md and col-xs for responsiveness, and now I can't figure out how to fit every image no matter how big it is to be a fixed width and height. Ive tried percentage and px, but then it loses its mobility and responsiveness and stays fixed on that width. Here is a picture of the problem http://postimg.org/image/n4tnblczd/ . I would be very thankfull on some advice how to resize big pictures to fixed width and heights but to remain it's responsiveness.
Before asking question suggest as giving your sample code. I think you want to know the process of html structure.
Use below html code for bootstrap support. col-md and col-sm in div class. img class will be "img-responsive" . It will get bootstrap.min.css
<div class="col-md-6 col-sm-6 col-xs-12 text-left">
<img src="/images/choose-us.png" class="img-responsive">
</div>
Use this I think it will solve your problem.here is screenshot I applied using my css with different image size.
Below snippet code not displaying exact style because of bootstrap css link.
.thumbnail{
padding: 0px;
border-radius: 0px;
position: relative;
border: 1px solid #222;
}
.thumbnail img{
height: 347px;
}
.drzac{
margin-top: 30px;
}
.overlay{
display: block;
transition: all 0.3s;
-webkit-transition: all 0.3s;
background-color: rgba(50, 200, 235, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
font-size: 2em;
text-align: center;
}
<div class="col-xs-6 col-md-4">
<div class="thumbnail">
<img src="http://www.it4gen.com/wp-content/uploads/2013/02/learnindoorgrowing.com_-460x345.png" class="img-responsive">
<div class="centered"><i class="fa fa-search"></i></div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="thumbnail">
<img src="http://www.totalcableusa.com/images/choose-us.png">
<div class="centered"><i class="fa fa-search"></i></div>
</div>
</div>
<div class="col-xs-6 col-md-4">
<div class="thumbnail">
<img src="http://www.totalcableusa.com/images/choose-us.png">
<div class="centered"><i class="fa fa-search"></i></div>
</div>
</div>

positioning a background on a link and make it scalable as well

I am trying to setup my layout on the mobile-first way. In the orange area here I have a link with class="logo". But for some reason the logo does not appear at all.
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 bg bg-blue"></div>
</div>
<div class="row">
<div class="col-xs-12 bg bg-orange">
test
</div>
</div>
<div class="row">
<div class="col-xs-12 bg bg-white"></div>
</div>
<div class="row">
<div class="col-xs-12 bg efrat"></div>
</div>
</div>
And some relevant CSS
.bg-orange {
position: absolute;
top: 3%;
background-color: #f7942e;
height: 25%;
}
.bg-orange a.logo {
background: url(//placehold.it/480X91) no-repeat center;
text-indent: -9999px;
display: inline-block;
max-width: 100%;
}
For the full example please see: here
How can I achieve this?
Thanks
You need to show us some of YOUR's code... But for that. also you must display a as block or something similar for background:url work.
Use this
.bg-orange a.logo {
background: url("http://placehold.it/480X91") no-repeat center;
text-indent: -9999px;
display: inline-block;
width:480px;
height:91px;
margin: 0 auto;
}

Trouble resizing bootstrap 3 box to fit with image

Please see the first image below.
This is working great and is how I want it to look. However when the browser resizes it then looks like this.
As you can see the white background of the text block is bigger than of the image block. I want the image block to be the same height as the text block but unfortunately this is not working. I am using Bootstrap 3 to develop this and you can see my code for this below:
<div class="row" style="margin-bottom:30px;">
<div class="col-xs-12">
<div class="col-sm-3" style="padding:0;">
<img src="core/img/abb[square].jpg" class="img-responsive">
</div>
<div class="col-sm-9" style="background:#fff; height:218px; padding:7px 25px;">
<h2><a class="a-cl">Page title</a> <small>2.1 miles away</small></h2>
<p>Text content, summary of page here.</p>
Subscribed <i class="glyphicon glyphicon-ok" style="margin-left:4px;"></i>
</div>
</div>
</div>
Any help would be much appreciated. As you can see I have manually defined the height on <div class="col-sm-9"> and set height:218px. This obviously will not work dynamically as the page resizes.
Summary: I am looking for an effective way of making sure the height of the text block is the same as the image block using bootstrap 3.
Okay, this is with intrinsic ratios, it's not like the comments I made. However, the comment about the rows and columns and nesting are correct.
DEMO: http://jsbin.com/zodama/1/
http://jsbin.com/zodama/1/edit
Requires: jquery.matchHeight-min.js
https://github.com/liabru/jquery-match-height
jQuery (when the script is installed):
$(document).ready(function() {
$('.my-row [class*="col-"]').matchHeight();
});
The CSS, some of which is the aspect ratio and some of which is Bootstrap grid manipulation based on intimate knowledge of how it works.
.my-row {
border: 10px solid #ddd;
margin-left: 0;
margin-right: 0;
margin-bottom: 3%;
text-align: center;
}
.image img {
display: block;
max-width: 100%;
height: auto;
margin: 0 auto;
}
.my-row [class*="col-"] {
padding:0 0 10px 0;
}
#media (min-width:768px) {
.my-row {
border: 10px solid #ddd; /* remove this it's in the global */
text-align: left;
}
.my-row [class*="col-"] {
padding: 0;
min-height: 220px;
}
.my-row [class*="col-"]:last-child {
padding-left: 20px;
padding-bottom: 20px;
}
.image img {
display: block;
width: 100%;
height: 100%;
margin: auto;
-webkit-transition: all 2s ease-out;
transition: all 2s ease-out;
}
.image img {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.image {
position: relative;
height: 0;
padding-top: 56.25%;
}
}
#media (min-width:992px) {
.my-row [class*="col-"] {
min-height: 250px;
}
}
#media (min-width:1200px) {
.my-row [class*="col-"] {
min-height: 275px;
}
}
HTML
<div class="container">
<div class="row my-row">
<div class="col-sm-4 col-md-3 image">
<img src="http://lorempixel.com/320/320/sports"/>
</div>
<div class="col-sm-8 col-md-9">
<h2><a class="a-cl">Page title</a> <small>2.1 miles away</small></h2>
<p>Text content, summary of page here.</p>
Subscribed <i class="glyphicon glyphicon-ok"></i>
</div>
</div>
<div class="row my-row">
<div class="col-sm-4 col-md-3 image">
<img src="http://lorempixel.com/320/320/city"/>
</div>
<div class="col-sm-8 col-md-9">
<h2><a class="a-cl">Page title</a> <small>2.1 miles away</small></h2>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
<p>Text content, summary of page here.</p>
Subscribed <i class="glyphicon glyphicon-ok"></i>
</div>
</div>