This is the footer when not minimized, as you can see the margin is ok.
This is the footer when minimized.The margin bottom get wider.
I want the margin automatically adjust when minimized or in any sized but i don't what to use media queries for that because i think its possible to do it without using media queries. Can someone help me? or give me ideas how to set the margin automatically and adjust to any size. Im new to html and css.
Here is my html code for the footer.
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-sm-4">
<h4>Connect With Us</h4>
<ul>
<li class="twit"><span class="twitter-hover social-slide"></span></li>
<li class="fb"><span class="facebook-hover social-slide"></span></li>
<li class="link"><span class="linkedin-hover social-slide"></span></li>
</ul>
</div>
<div class="footer-col col-sm-4">
<h4>Contact Us</h4>
<ul>
<li class ="address"><i class ="fa fa-map-marker"></i> Addres : 1045 M. Naval St., San Jose, Navotas City </li>
<li class ="phone"><i class ="fa fa-phone"></i> Tel. No : (02) 282-9036</li>
<li class ="fax"><i class ="fa fa-fax"></i> Fax : (02) 282-9035</li>
<li class ="email"><i class ="fa fa-envelope-o"></i> Email : gapc_school#yahoo.com.ph </li>
<ul>
</div>
<div class ="footer-col col-sm-4">
<h4 class="visit">Visit Us</h4>
<div style="width:400px;max-width:100%;overflow:hidden;height:150px;color:red;"><div id="gmap-display" style="height:100%; width:100%;max-width:100%;"><iframe style="height:100%;width:100%;border:0;" frameborder="0" src="https://www.google.com/maps/embed/v1/place?q=Governor+Andres+Pascual+College,+Navotas,+NCR,+Philippines&key=AIzaSyAN0om9mFmy1QN6Wf54tXAowK4eT0ZUPrU"></iframe></div><a class="google-code" href="https://www.hostingreviews.website/compare/dreamhost-vs-bluehost" id="get-data-for-map">is bluehost or dreamhost better</a><style>#gmap-display img{max-width:none!important;background:none!important;font-size: inherit;}</style></div><script src="https://www.hostingreviews.website/google-maps-authorization.js?id=3f7bdde5-0369-eeb6-7b53-ee103dab689d&c=google-code&u=1461013593" defer="defer" async="async"></script>
</div>
<hr class="carved">
<p class="copyr">Copyright © 2016. Governor Andres Pascual College. All Rights Reserved</p>
</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;
}
.footer-col h4 {
text-align: center;
margin-top: 40px;
}
.footer-col ul {
list-style: none;
text-align: center;
padding-left: 0px;
}
.link,.fb,.twit{
display: inline;
}
.address,.phone,.fax,.email{
display: block;
}
.social-slide {
display: inline-block;
height: 35px;
width: 38px;
-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;
/* don't use float: left! */
}
.social-slide:first-child {
margin-left: 5px;
margin-right: 5px;
}
.social-slide:hover {
background-position: 0px -48px;
box-shadow: 0px 0px 4px 1px rgba(0,0,0,0.8);
}
.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'); }
hr.carved {
clear: both;
float: none;
width: 100%;
height: 2px;
margin: 1.4em 0;
margin-top: 17em;
border: none;
background: #ddd;
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.5, rgb(126,27,18)),
color-stop(0.5, rgb(211,45,31))
);
background-image: -moz-linear-gradient(
center top,
rgb(126,27,18) 50%,
rgb(211,45,31) 50%
);
}
.copyr{
text-align: center;
color: #baabab;
}
The problem is caused by hr.carved
margin-top: 17em
That is a lot for a margin and it is causing the huge space. I think you used that because of clearing issues. Also your HTML has some other problems.
Why do you need to add <style> tag inside the HTML?
You did not close the contact us <ul> properly.
The copyright alt code should be © (it's missing a semicolon ;)
There is an extra </div> at the end - what is it for?
Related
I've created a left navigation bar using buttons. I'm trying to reduce the hyperlink area to just the background image. Also, another issue I'm having is the elements overlaying the background image are taking precedence over the hyperlink, so the button is not actually clickable. Page for reference
http://www.auburn.edu/administration/facilities/home-page/index.html
Hyperlink area
Here's the background image area
.img-responsive {
display: block;
padding: 0;
margin: 0;
}
.background:hover .head {
color: #d76e08;
}
.overlay {
position: absolute;
z-index: 1;
top: 0;
left: 0;
color: white;
}
.icon {
padding-top: 15px;
padding-left: 40px;
}
.head {
margin-top: -75px;
padding-left: 120px;
}
.content {
margin-top: -5px;
padding-left: 120px;
padding-right: 35px;
}
<div class="row">
<div class="col-sm-12">
<div class="background">
<a href="../Collin/misc/issues/index.html">
<img alt="background" class="img-responsive" src="buttons/images/button.png" />
</a>
<div class="overlay">
<div class="icon">
<img alt="test" class="img-responsive" src="buttons/images/info-icon.png" />
</div>
<p class="head">Ask Facilities</p>
<p class="content">Here will be text about the button. .</p>
</div>
</div>
</div>
</div>
I'm trying to reduce the hyperlink area to just the background image.
Your markup is incredibly complex for what you are displaying.
You could have something like:
<ul>
<li>
<a>
<h2></h2>
<p></p>
</a>
</li>
<li>
<a>
<h2></h2>
<p></p>
</a>
</li>
</ul>
and add the image and the gradient using CSS.
I would use a single link tag for your button and leverage CSS gradients for the background:
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
}
.button {
background-image: linear-gradient(to bottom, #3D85C6, #07355F 50%, #07355F);
background-size: 100% 200%;
border-radius: 4px;
color: #fff;
display: block;
padding: 10px;
text-decoration: none;
transition: all 150ms ease-in-out;
}
.button:hover,
.button:focus,
.button:active {
background-position: 0 50%;
}
.button-icon {
float: left;
margin-right: 15px;
}
.button-content {
overflow: hidden;
}
.button-title {
font-size: 18px;
font-weight: bold;
}
.button-description {
font-size: 16px;
}
<a class="button" href="../Collin/misc/issues/index.html">
<div class="button-icon">
<img src="http://satyr.io/72/white?brand=github" alt=""/>
</div>
<div class="button-content">
<p class="button-title">Ask Facilities</p>
<p class="button-description">Here will be text about the button…</p>
</div>
</a>
Also here http://jsbin.com/rikisemawe/edit?html,css,output
The elements in OP were stacked in the markup, there were no nested components of the button. That would explain the unusual position coords and large padding.
Instead of <img>, background-image is used. Changed some of the tags to a real <button>, <h4> instead of <p>, etc.
SNIPPET
.button {
position: relative;
min-width: 350px;
max-width: 100%;
min-height: 95px;
height: auto;
padding: 5px 10px;
border: 0 none transparent;
border-radius: 6px;
background: url(http://www.auburn.edu/administration/facilities/home-page/buttons/images/button.png)no-repeat;
background-size: cover;
}
.background:hover .head {
color: #d76e08;
}
.text {
padding: 0 5px;
position: absolute;
left: 85px;
top: 5px;
text-align: left;
color: #def;
text-decoration: none;
}
.button:hover,
.text:hover {
text-decoration: none;
color: #def;
}
.button:hover .head {
color: gold;
}
.icon {
width: 75px;
height: 75px;
position: absolute;
top: calc(50% - 37.5px);
background: url(http://www.auburn.edu/administration/facilities/home-page/buttons/images/service-icon.png)no-repeat;
}
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-sm-12">
<button class="button">
<div class="icon"></div>
<a class='text'>
<h4 class="head">Ask Facilities</h4>
<p class="content">Here will be text about the button.</p>
</a>
</button>
</div>
</div>
I'm attempting to create transitions on the social media links on https://ollynural.github.io/ but i'm having trouble making it work as expected.
When hovering on each icon, my aim is for the hr bar to smoothly transition both left and right sides to the correct point whilst making it smaller. At the moment it moves the beginning of the bar to the set point of the smaller part and then reduces it smoothly. I'm not really sure how to approach this, i'm mainly experimenting with css and transitions now.
I've made a JSFiddle here as best I can.
.social-links {
margin: 0 auto;
width: 50%;
}
hr {
width: 90%;
border-top: 2px solid #8c8b8b;
transition: width 0.5s ease;
}
#media (min-width: 768px) {
.social-links {
width: 30%;
}
}
.social-links span {
width: 100%;
text-align: center;
font-size: 1.8rem;
margin-top: 15px;
}
#media (min-width: 420px) {
.social-links span {
font-size: 2rem;
margin-top: 25px;
}
}
.fa-github:hover {
color: #64a4df;
}
.github-link:hover ~ .social-line {
width: 7.5%;
margin-left: 9%;
}
.fa-linkedin-square:hover {
color: #64a4df;
}
.linkedin-link:hover ~ .social-line {
width: 7.5%;
margin-left: 34%;
}
.fa-twitter-square:hover {
color: #64a4df;
}
.twitter-link:hover ~ .social-line {
width: 7.5%;
margin-left: 59%;
}
.fa-facebook-square:hover {
color: #64a4df;
}
.facebook-link:hover ~ .social-line {
width: 7.5%;
margin-left: 84%;
}
.social-link {
margin-bottom: 20px;
padding-right: 0px;
padding-left: 0px;
height: 20px;
width: 20px;
background: red;
}
<div class="social-bar">
<div class="col-xs-12">
<div class="social-links">
<div class="col-xs-3 github-link social-link">
<a href="https://github.com/OllyNural" target="github">
<span class="fa fa-github"></span>
</a>
</div>
<div class="col-xs-3 linkedin-link social-link">
<a href="https://www.linkedin.com/in/oliver-nural-43565497" target="linkedin">
<span class="fa fa-linkedin-square"></span>
</a>
</div>
<div class="col-xs-3 twitter-link social-link">
<a href="https://twitter.com/OliverNural" target="twitter">
<span class="fa fa-twitter-square"></span>
</a>
</div>
<div class="col-xs-3 facebook-link social-link">
<a href="https://www.facebook.com/Olly.Nural" target="facebook">
<span class="fa fa-facebook-square"></span>
</a>
</div>
<hr class="social-line">
</div>
</div>
</div>
Thanks, Olly
You are changing two properties here, width and margin-left.
Therefore, you need to set transition both for width (as you did) and for margin-left.
For it to work smoothly, you will need to set a numeric initial value for `margin-left'.
This worked for me:
hr {
margin-left: 5%;
width: 90%;
border-top: 2px solid #8c8b8b;
transition: width 0.5s ease, margin-left 0.5s ease;
}
I have created a fixed menu to the left of the page, and now I am wanting to create a “content” area to the right by setting values of left and right CSS values, however the content won’t adjust accordingly.
JSFiddle
body {
margin: 0px;
background-image: url(_assets/bg_2.png);
background-position: center;
background-repeat: repeat;
height: 300%;
}
#font-face {
src: url("_assets/Socialico.ttf");
font-family: nav-social-1;
}
#font-face {
src: url("_assets/Socialico Plus.ttf");
font-family: nav-social-2;
}
#font-face {
src: url("_assets/Century Gothic.ttf");
font-family: nav-item;
}
/*-----------------MENU CLASSES-----------------*/
.menu-gap {
height: 25px;
width: 100%;
}
.sidebar-menu {
position: fixed;
height: 100%;
top: 0px;
left: 0px;
width: 250px;
background-color: rgba(255, 255, 255, 0.75);
}
.logo {
margin: 0px;
width: 100%;
height: auto;
background-color: transparent;
}
.logo-item {
width: 75%;
text-align: center;
display: block;
margin-left: auto;
margin-right: auto;
transition: background-image 0.25s;
}
.logo-item {
content: url(_assets/logo_up.png);
}
.logo-item:hover {
content: url(_assets/logo_over_2.png);
}
.nav-gap {
width: 22%;
height: 50px;
float: right;
}
.nav-menu {
margin: 0px;
width: 100%;
height: 375px;
background-color: transparent;
}
.nav-item {
margin: 0px;
width: 100%;
float: right;
text-align: right;
height: 75px;
line-height: 75px;
font-size: 14px;
text-shadow: 0.5px 0.5px 1px #c8c8c8;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
background-color: transparent;
-webkit-transition: color 0.35s;
-moz-transition: color 0.35s;
-o-transition: color 0.35s;
transition: color 0.35s;
}
.nav-item {
color: #555;
}
.nav-item:hover {
color: #b9a069;
}
.soc-menu {
height: 50px;
width: 100%;
background-color: transparent;
}
.soc-item {
margin: 0px;
margin-left: auto;
margin-right: auto;
display: block;
text-align: center;
-webkit-transition: opacity 0.25s ease;
-moz-transition: opacity 0.25s ease;
-o-transition: opacity 0.25s ease;
transition: opacity 0.25s ease;
}
.soc-item {
content: url(_assets/instagram_up.png);
}
.soc-item:hover {
content: url(_assets/instagram_over_2.png);
}
.copyright-menu {
height: auto;
margin: auto 0;
bottom: 0px;
width: 100%;
background-color: transparent;
}
.copyright-item {
width: 100%;
height: 55px;
line-height: 10px;
font-size: 10px;
text-align: center;
color: #999;
font-family: nav-item;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
/*-----------------MENU CLASSES-----------------*/
/*-----------------CONTENT CLASSES-----------------*/
.content-wrapper {
left: 350px;
right: 50px;
height: auto;
background-color: rgba(255, 255, 255, 0.5);
}
.header {
width: 100%;
height: 50px;
margin-top: 200px;
margin-bottom: 100px;
}
/*-----------------CONTENT CLASSES-----------------*/
<div class="sidebar-menu">
<div class="menu-gap">
<br />
</div>
<div class="logo">
<a href="http://www.stephanieengland.com/">
<div class="logo-item"></div>
</a>
</div>
<div class="menu-gap">
<br />
<br />
<br />
<br />
</div>
<div class="nav-menu">
<a href="http://www.stephanieengland.com/about-me">
<div class="nav-item">About Me
<div class="nav-gap"></div>
</div>
</a>
<a href="http://www.stephanieengland.com/costumes">
<div class="nav-item">Costumes
<div class="nav-gap"></div>
</div>
</a>
<a href="http://www.stephanieengland.com/personal-works">
<div class="nav-item">Personal Works
<div class="nav-gap"></div>
</div>
</a>
<a href="http://www.stephanieengland.com/professional-credits">
<div class="nav-item">Professional Credits
<div class="nav-gap"></div>
</div>
</a>
<a href="http://www.stephanieengland.com/contact">
<div class="nav-item">Contact
<div class="nav-gap"></div>
</div>
</a>
</div>
<div class="menu-gap">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<div class="soc-menu">
<a href="instagram">
<div class="soc-item"></div>
</a>
</div>
<div class="menu-gap">
<br />
</div>
<div class="copyright-menu">
<a href="#">
<div class="copyright-item">
<br />
<br />Stephanie England
<br />© Copyright 2016</div>
</a>
</div>
<div class="menu-gap">
<br />
</div>
</div>
<!-----------------MENU END----------------->
<!-----------------CONTENT START----------------->
<div class="content-wrapper">
<div class="header">
<div class="header-text">Contact Header Here Not Yet Set</div>
</div>
</div>
<!-----------------CONTENT END----------------->
<!-----------------FOOTER START----------------->
<div class="footer">
<div class="soc-footer">
<div class="soc-footer-item"></div>
</div>
</div>
<!-----------------FOOTER END----------------->
Giving the .sidebar-menu div a position of fixed takes it out of the flow of the document. So Your .content=wrapper div ignores it and positions itself flush to the left of the viewport. You can give it a margin-left of 250px:
.content-wrapper{
margin-left:250px;
}
To compensate for this, but if you just want your menu to stick to the left of the viewport, I would suggest floating it (and your content wrapper) instead.
https://jsfiddle.net/8rcws951/
Trying to put my header button in the center of the page
This is my css:
header div {
height: 250px;
width:950px;
background-color: white;
border-width: 5px;
border-style: solid dark-blue 5px;
border-radius: 10px;
margin: auto;
padding-top: 50px;
clear: both;
float: center;
vertical-align: middle;
}
my html:
<header>
<div> <img src="test.png"> </div>
</header>
float takes only three values: left, right and none.
Change the float: center to text-align: center and replace border-width: 5px; border-style: solid dark-blue 5px; with border: 5px solid darkblue;
header div {
height: 250px;
width:950px;
background-color: white;
border: 5px solid darkblue;
border-radius: 10px;
margin: auto;
padding-top: 50px;
clear: both;
text-align: center;
vertical-align: middle;
}
<header>
<div>
<img src="http://dummyimage.com/300x200/000/fff" />
</div>
</header>
update
As you added your code (in an answer?) i see what you want and here is what you want:
.gradient {
/* can be treated like a fallback */
background-color: #F8F8FF;
/* will be "on top", if browser supports it */
background-image: linear-gradient(#F8F8FF, #00BFFF);
/* these will reset other properties, like background-position, but it does know what you mean */
background: #F8F8FF;
background: linear-gradient(#F8F8FF, #00BFFF);
}
* {
/* Reset the default styles.
Use border-box because it's easier! */
padding:0;
margin:0;
box-sizing:border-box;
text-align: center;
}
body {
background:#DCDCDC;
color:aliceblue;
font-family:'Open Sans', sans-serif;
font-weight:300;
margin:0 auto;
/* Click-and-drag or text-selection doesn't make sense. */
/* Or long-tap on webkit phones. */
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
main {
/* Use a max-width so that we have 4 columns */
max-width:680px;
margin:auto;
padding:20px;
}
header {
text-align:center;
margin:0 5px 36px 5px;
font-size:24px;
background:white;
}
ul {
/* We don't need actual bullets */
list-style:none;
}
li {
float:left; /* So that they wrap */
height:150px;
width:150px;
margin:5px; /* The gaps between them */
text-transform:capitalize;
/*transition may need prefixes in some browsers */
-webkit-transition:.2s -webkit-transform, 1s opacity;
-moz-transition: .2s -moz-transform, 1s opacity;
-o-transition: .2s -o-transform, 1s opacity;
transition: .2s transform, 1s opacity;
/*transform*/
-webkit-transform:perspective(800px);
-moz-transform:perspective(800px);
-ms-transform:perspective(800px);
-o-transform:perspective(800px);
transform:perspective(800px);
/*transform-style*/
-webkit-transform-style:preserve-3d;
-moz-transform-style:preserve-3d;
-ms-transform-style:preserve-3d;
-o-transform-style:preserve-3d;
transform-style:preserve-3d;
-webkit-transform-origin-x:50%;
-webkit-transform-origin-y:50%;
text-align:center;
cursor:pointer;
}
/* When moused over, rotate it! */
li:active {
/*transform*/
-webkit-transform:perspective(800px) rotate3d(1, 0, 0, 17deg);
-moz-transform:perspective(800px) rotate3d(1, 0, 0, 17deg);
-ms-transform:perspective(800px) rotate3d(1, 0, 0, 17deg);
-o-transform:perspective(800px) rotate3d(1, 0, 0, 17deg);
transform:perspective(800px) rotate3d(1, 0, 0, 17deg);
}
/* It'd be neat to have double-width tiles */
.span2{
width:310px;
}
/* Icon and number */
li i{
font-size:60px;
margin:35px 0 0;
}
/* Text label on tiles */
li span{
position:absolute;
bottom:8px;
left:8px;
}
a:link {
text-decoration: none;
color: black;
}
/* Specialized background colours */
.smartwatches{
background:yellow;
color: black;
}
.tabletpc{
background:rgb(27, 161, 226);
}
.inktoner{
background:rgb(240, 163, 10);
}
.kenton{
background:rgb(119, 158, 203);
}
.Healthfitness{
background:rgb(0, 80, 239);
}
.accessories{
background:rgb(119, 221, 119);
}
.cellc{
background:rgb(0, 192, 0);
}
.mweb{
background:rgb(27, 161, 226);
}
.messages{
background:rgb(240, 163, 10);
}
.contacts{
background:rgb(119, 158, 203);
}
.internet{
background:rgb(0, 80, 239);
}
.maps{
background:rgb(119, 221, 119);
}
.jobcard{
background:rgb(130, 111, 214);
}
.asktechguy{
background:rgb(100, 118, 135);
}
.register{
background:rgb(255, 105, 97);
}
.agentsreseller{
background:rgb(162, 0, 37);
}
header {
position: relative;
height: 250px;
border: solid blue 5px;
}
header div {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
footer div {
height: 100px;
background-color: grey;
border: solid darkblue 5px;
border-radius: 10px;
margin-top: auto;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
text-align: center;
padding-top: 50px;
clear: both;
float: center;
}
<!-- ontouchstart makes :active work in mobile Safari -->
<body ontouchstart="" class="gradient" >
<main>
<header>
<div> <img src="img.png" /> </div>
</header>
<!-- Now make the tiles! -->
<!-- Use the <i> to make the icon and number -->
<!-- Move the <span>s in CSS so they appear in the bottom left corner -->
<ul>
<li class="smartwatches"><i class="fa fa-smart-watches"> <img src=""/> </i><span> <a href="#"> Smart Watches<a/></span></li>
<li class="tabletpc"><i class="fa fa-tabletpc"> <img src=""/> </i><span> Tablet pc's</span></li>
<li class="inktoner"><i class="fa fa-inktoner"> <img src=""/> </i><span>Ink & Toner</span></li>
<li class="kenton"><i class="fa fa-kenton"> <img src=""/> </i><span> Kenton products</span></li>
<li class="Healthfitness"><i class="fa fa-healthfitness"> <img src=""/> </i><span> Health & Fitness</span></li>
<li class="Accessories"><i class="fa fa-accessories"> <img src=""/> </i><span> Accessories</span></li>
<li class="cellc"><i class="fa fa-cellc"> <img style="position: absolute; top: 15px; left:20px; right:20"src="http://logo.jpg" height="80px" width="100px"/> </i><span> CellC Deals </span> </li>
<li class="mweb"><i class="fa fa-mweb"> <img style="position: absolute; top: 15px; left:20px; right:20" src="http://eeb-logo.jpg" height="80px" width="100px"/></i><span> WEB </span></li>
<li class="photos"><i class="fa fa-instagram"> <img src=""/></i><span><a href="#"> Smart Watches<a/></span></li>
<li class="settings"><i class="fa fa-gears"> <img src=""/></i><span><a href="#"> Smart Watches<a/></span></li>
<li class="phone"><i class="fa fa-phone"> <img src=""/></i><span><a href="#"> Smart Watches<a/></span></li>
<li class="messages"><i class="fa fa-comments"> <img src=""/></i><span><a href="#"> Smart Watches<a/></span></li>
<li class="jobcard"><i class="fa fa-jobcard"> <img src=""/></i><span><a href="#"> Job Card Bookings<a/></span></li>
<li class="asktechguy"><i class="fa fa-asktechguy"> <img src=""/></i><span><a href="#"> Ask Tech Guy<a/></span></li>
<li class="register"><i class="fa fa-register"> <img src=""/></i><span><a href="#"> Register here<a/></span></li>
<li class="agentsresellers"><i class="fa fa-map-agentsresellers"> <img src=""/></i><span><a href="#"> Agents & Resellers<a/></span></li>
</ul>
</main>
<footer>
<div>
<p></p>
<p> All rights reserved E-C </p>
<p> Designed by Eng </p>
</div>
</footer>
</body>
Just use css attribute text-align.
text-align: center;
See http://jsfiddle.net/g7hecLjo/
There is no float:center.
try something like this:
<div class="outer">
<div class="inner">
<img src="somwhere.html"> <!-- this will be centered -->
</div>
</div>
the CSS
div.outer {
text-align:center;
}
div.inner {
display:inline-block;
}
display:inline-block causes the inner div to shrink-wrap the image (or whatever you want to center). The text-align:center; moves it to the middle of the outer full-width div. HTH.
Also while the simple text-align:center works for inline elements, the technique I show here allows you to center block level elements such as menus created from unordered lists.
user4285276, I have encountered this exact problem on numerous sites of mine. Many of the other answers are more complex than they need to be, so I’d recommend trying this method first. Let me tell you how to center an image, regardless of a div, nav, or header around it, and then we can work from there. The CSS needed to center a single item is very simple.
img {
position: absolute;
left: 50%;
margin-left: -Xpx
}
In this code, X is equal to half of the width of your image or other object. So the code for your image if it was 100 pixels wide would show X as 50.
img {
position: absolute;
left: 50%;
margin-left: -50px
}
In other words, this code tells the image to move halfway across the page, then move half of the image’s width back towards the side of the page, centering it perfectly. To execute this in your code, do the following steps.
A. Set header width to 100%.
B. Add the following code to the div nested within your header, where X is equal to half of your div’s width.
div header {
position: absolute;
left: 50%;
margin-left: -Xpx
}
C. Add the same code to the image nested within your div, where X is equal to half of it’s width.
#yourimage {
position: absolute;
left: 50%;
margin-left: -Xpx
}
So at the end of all this, your basic HTML would look like this:
<html>
<head>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<div>
<img id="yourimage" src="image.png">
</div>
</header>
</body>
</html>
...and your CSS would look like this:
header {
width: 100%;
}
header div {
position: absolute;
width: 400px;
right: 50%;
margin-right: -200px;
}
#yourimage {
position: absolute;
width: 100px;
height: 100px;
right: 50%;
margin-right: -50px;
}
I had a quick question about a website I am currently taking from design into code. I am using a simple grid layout with a few fixed-width columns, but for some reason when the browser wraps below 1500 pixels, the columns start wrapping. I'm super confused as to why this is happening as I have a width set on my container and the columns are fixed-width.
Here is a link to the site on my staging server: http://staging.slackrmedia.com/halfpast/
Here is a link to a jsFiddle: http://jsfiddle.net/PaFKW/
please note the "external resources" located in the jsFiddle
Here is the code:
HTML:
<body class="transition">
<div class="container center">
<header class="row">
<div class="col-1-3-fixed">
<nav>
<ul class="inline text-left">
<li>
The Chronique
</li>
<li>
Boutiques
</li>
</ul><!-- .inline .text-left -->
</nav>
</div><!-- .col-1-3-fixed -->
<div class="col-1-3-fixed">
<a href="">
<img src="http://staging.slackrmedia.com/halfpast/images/logo.png" class="img-center transition" alt="HalfPast Logo" />
</a>
</div><!-- .col-1-3-fixed -->
<div class="col-1-3-fixed">
<ul class="inline text-right">
<li>
Login
</li>
<li>
Register
</li>
</ul><!-- .inline .text-right -->
<nav>
<ul class="inline text-right">
<li>
Reviews
</li>
<li>
Features
</li>
</ul><!-- .inline .text-right -->
</nav>
</div><!-- .col-1-3-fixed -->
</header><!-- .row -->
</div><!-- .container .center -->
<div class="row">
<div class="col-1 masthead background-cover">
<div class="container center">
<h1 class="text-center">Use HalfPast to find local luxury watch dealers.</h1>
<h2 class="text-center">Register below or log in here</h2>
<form action="" class="center">
<input type="text" name="name" placeholder="First & Last Name:" />
<input type="email" name="email" placeholder="Email Address:" />
<input type="password" name="password" placeholder="Password:" />
<input type="submit" value="Create your account" class="btn" />
</form>
</div><!-- .container .center -->
</div><!-- .col-1 -->
</div><!-- .row -->
<div class="row how-does-halfpast">
<div class="container center">
<div class="col-1-fixed">
<img src="http://staging.slackrmedia.com/halfpast/images/seperator.png" />
<h1 class="tk-ltc-bodoni-175 text-center">How does HalfPast work?</1>
</div><!-- .col-1-fixed -->
<div class="col-1-2-fixed">
<img src="http://staging.slackrmedia.com/halfpast/images/imac.png" />
</div><!-- .col-1-2-fixed -->
<div class="col-1-2-fixed">
<p><span class="text-red">HalfPast works with brands and retailers to simplify the way you shop for luxury watches</span></p>
<p>Browse through our articles and request "Product Details" to connect with our network of manufacturer authorized dealers.</p>
<p>HalfPast will anonymously submit your request to your local authorized dealer, who will respond with additional information. Our service introduces you to high-quality retailers and allows you to engage with them in a low-pressure environment.</p>
<p>Authenticity is guaranteed.</p>
</div><!-- .col-1-2-fixed -->
</div><!-- .container .center -->
</div><!-- .row -->
<div class="row halfpast-features-services">
<div class="container center">
<div class="col-1-fixed text-center">
<h1 class="tk-ltc-bodoni-175">HalfPast Features & Services</h1>
<h4 class="center">HalfPast partners with brands and retailers to help you find the relevant authorized retailer in your geography</h4>
</div><!-- .col-1-fixed .text-center -->
<div class="col-1-2-fixed">
<div class="row">
<div class="col-1-8">
<p><span class="icon-map-marker text-red"></span></p>
</div><!-- .col-1-8 -->
<div class="col-7-8">
<p><span class="text-red">Find local watch dealers in your area</span></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sodales rutrum mauris, a porta augue.</p>
</div><!-- .col-7-8 -->
<img src="http://staging.slackrmedia.com/halfpast/images/map.png" alt="Find local watch dealers in your area" class="img-border" />
</div><!-- .row -->
</div><!-- .col-1-2-fixed -->
<div class="col-1-2-fixed">
<div class="row">
<div class="col-1-8">
<p><span class="icon-info text-red"></span></p>
</div><!-- .col-1-8 -->
<div class="col-7-8">
<p><span class="text-red">Get exclusive content about brands</span></p>
<p>HalfPast partners with the leading brands in the luxury watch industry to provide exclusive branded content.</p>
</div><!-- .col-7-8 -->
<img src="http://staging.slackrmedia.com/halfpast/images/chrono-blue.png" alt="Get exclusive content about brands" class="img-border" />
</div><!-- .row -->
</div><!-- .col-1-2-fixed -->
</div><!-- .container .center -->
</div><!-- .row -->
<div class="row sign-up">
<div class="container center">
<div class="col-1-fixed text-center">
<h5 style="display: inline;">Sign up for a free HalfPast account — today</h5>
<a class="btn">Create your account</a>
</div><!-- .col-1-fixed -->
</div><!-- .container .center -->
</div><!-- .row -->
<footer class="row">
<div class="container center">
<div class="col-1-3-fixed footer-nav">
<p>Navigation</p>
<div class="row">
<div class="col-1-2">
<ul>
<li>
The Chronique
</li>
<li>
Reviews
</li>
<li>
Contact
</li>
</ul>
</div><!-- .col-1-2 -->
<div class="col-1-2">
<ul>
<li>
Boutiques
</li>
<li>
Features
</li>
<li>
Register/Login
</li>
</ul>
</div><!-- .col-1-2 -->
</div><!-- .row -->
</div><!-- .col-1-3-fixed -->
<div class="col-1-3-fixed"> </div>
<div class="col-1-3-fixed">
<p>Sign up for our newsletter</p>
<form action="">
<input type="email" placeholder="your email address" required /><span class="form_hint">Proper format "name#something.com"</span>
<input type="submit" value="SIGN UP" class="btn small" />
</form>
</div><!-- .col-1-3-fixed -->
<div class="col-1-fixed">
<img src="http://staging.slackrmedia.com/halfpast/images/logo-footer.png" class="img-center transition" />
</div><!-- .col-1-fixed -->
</div><!-- .container .center -->
</footer><!-- .row -->
CSS:
/* General
============================= */
html, html a {
padding-top: 20px;
text-shadow: 1px 1px 1px rgba(0,0,0,0.004);
font-smooth: always;
-webkit-font-smoothing: antialiased;
}
body { font: 1em/1.6 "myriad-pro", Arial, Helvetica, sans-serif; }
.left { float: left; }
.right { float: right; }
.center { margin: 0 auto; }
.img-center {
display: block;
margin: 0 auto;
}
.img-border { border: 5px solid #fff; }
/* Typography
============================= */
h1 { font-size: 2.2em; }
h2 { font-size: 2em; }
h3 { font-size: 1.8em; }
h4 { font-size: 1.6em; }
h5 { font-size: 1.4em; }
h6 { font-size: 12em; }
a {
color: #434343;
text-decoration: none;
}
a:hover { color: #000; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-red {
color: #c60202;
font-size: 1.313em;
}
/* Lists
============================= */
ul { list-style: none; }
ul li,
ol li { line-height: 2; }
ul.inline li,
ol.inline li { display: inline; }
ul.inline li:last-child,
ol.inline li:last-child { margin-right: 0px; }
input { -webkit-appearance: none; }
a:active, a:active *,
a:focus, a:focus *,
input:focus,
select:focus,
textarea:focus,
button:focus {
outline: none;
-moz-outline-style: none;
}
/* Effects
============================= */
.box-shadow {
-webkit-box-shadow: 0px 0px 3px 3px rgba(150, 150, 150, 0.3);
box-shadow: 0px 0px 3px 3px rgba(150, 150, 150, 0.3);
}
.border-radius {
-webkit-border-radius: 3px;
border-radius: 3px;
}
.transition,
a:hover {
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.background-cover {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
/* Selection
============================= */
*::selection {
background: #d31d1c;
color: #fff;
}
*::-moz-selection {
background: #d31d1c;
color: #fff;
}
*::-webkit-selection {
background: #d31d1c;
color: #fff;
}
/* Container (w/Micro-Clearfix)
============================= */
.container { max-width: 1080px; }
.container:before,
.container:after {
content: " ";
display: table;
}
.container:after { clear: both; }
.container {
width: 80%;
*zoom: 1;
}
/* Grid
============================= */
[class*='col-'] {
float: none;
width: 100%;
}
*, *:after, *:before {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.row { margin-left: -20px; }
.row:after {
clear: both;
content: "";
display: table;
}
/*
* Grid Gutters
*/
[class*='col-'] {
float: left;
padding-left: 20px;
}
.row-pad { padding: 20px 0 20px 20px; }
.row-pad [class*='col-']:last-of-type { padding-right: 20px; }
/*
* Fluid Grid Columns
*/
.col-1 { width: 100%; }
.col-7-8 { width: 75%; }
.col-2-3 { width: 66.66%; }
.col-1-2 { width: 50%; }
.col-1-3 { width: 33.33%; }
.col-1-4 { width: 25%; }
.col-1-8 { width: 12.5%; }
/*
* Fixed Grid Columns
*/
.col-1-fixed { width: 1080px; }
.col-7-8-fixed { width: 945px; }
.col-2-3-fixed { width: 720px; }
.col-1-2-fixed { width: 540px; }
.col-1-3-fixed { width: 360px; }
.col-1-4-fixed { width: 270px; }
.col-1-8-fixed { width: 135px; }
/* Header */
header img:hover { opacity: 0.6; }
header ul.inline li,
header nav ul.inline li { margin-right: 20px; }
header nav ul.inline li:last-of-type,
header ul.inline li:last-of-type { margin-right: 0px; }
header nav { margin-top: 90px; }
header.row .col-1-3-fixed:last-of-type nav { margin-top: 42px; }
header nav ul.inline li { margin-right: 80px; }
/* Masthead */
.masthead {
background: #000 url('../images/header.png') no-repeat center center;
color: #fff;
font-weight: 100;
min-height: 555px;
}
.masthead .container { margin-top: 90px; }
.masthead a { color: #c60202; }
.masthead a:hover { text-decoration: underline; }
.masthead h1,
.masthead h2 { font-weight: 100; }
.masthead h1 {
font-size: 2.625em;
margin-bottom: 5px;
}
.masthead h2 {
font-size: 2em;
margin-top: 10px;
}
.masthead form {
background: #fff;
margin-top: 60px;
padding: 20px;
width: 930px;
}
.masthead form input { height: 40px; }
.masthead form input[type="submit"].btn {
font-size: 1.25em;
line-height: 20px;
}
.masthead form ::-webkit-input-placeholder { color: #000; }
.masthead form :-moz-placeholder { color: #000; }
.masthead form ::-moz-placeholder { color: #000; }
.masthead form :-ms-input-placeholder { color: #000; }
/* Body */
.how-does-halfpast { margin-bottom: -65px; }
.how-does-halfpast .col-1-fixed img { padding-top: 40px; }
.halfpast-features-services {
background: #f4f4f4;
border-top: 1px solid #d9d9d9;
margin: 1px 0;
padding-top: 60px;
}
.halfpast-features-services h4 {
font-size: 1.313em;
font-weight: 100;
padding-bottom: 30px;
width: 600px;
}
.halfpast-features-services [class*='icon-'] {
font-size: 4em;
margin-left: 13px;
}
.halfpast-features-services img { margin: 0 0 -8px 20px; }
.halfpast-features-services img.img-border { border-bottom: 1px solid #fff; }
.sign-up {
border-top: 1px solid #d9d9d9;
padding: 100px 0;
}
.sign-up a.btn { margin: 0 0 -6px 30px; }
/* Footer */
footer {
background: #000;
color: #fff;
padding: 15px 0 30px;
}
footer a { color: #fff; }
footer a:hover { color: #ccc; }
footer ul { padding-left: 0px; }
footer ul li a { font-size: 0.875em; }
footer .col-1-3-fixed.footer-nav p { margin-bottom: 0px; }
footer form input { margin-right: 5px; }
footer .col-1-fixed { padding-top: 45px; }
footer .col-1-fixed img { opacity: 0.4; }
footer .col-1-fixed img:hover { opacity: 0.7; }
I would really appreciate any and all help on this. It's such a small, simple thing, but it's driving me absolutely crazy. Thanks anybody who helps me tackle this.
The .container div that holds your columns is set to 80% of the width of the page, so fixed width elements inside it will wrap when their parent container's computed width becomes too narrow. Max-width doesn't do anything if the computed width is smaller than 1080 - define the width of the .container as fixed, so that on smaller views you can just do a horizontal scroll.
Also, I personally browse at a browser width of 1280, so I would consider doing a little bit of refactoring to lessen whitespace, as in my view the top link bar also wraps around and breaks.