I have a menu and I can't center an ul inside second_nav. What's wrong with this menu?
This is my normal second nav
/*second_nav*/
#second_nav{
background: url("images/second_nav.png");
height: 255px;
width: 100%;
}
#second_nav ul{
display: block;
margin: 0 0 0 170px;
width: 654px;
position: absolute;
padding: 25px 0 0 0;
}
#second_nav ul li{
display: block;
float: left;
margin: 0 0 0 60px;
height: 220px;
}
#second_nav ul li p{
font-size: 20px;
font-weight: 300;
color: #000000;
text-align: center;
width: 80px;
margin: 0 auto;
}
and this is my second_nav when screen is max- 820px i want to center this.
#second_nav{
height: 255px;
width:100%;.
margin: 0 auto;
}
#second_nav ul{
height: 215px;
margin: 0 auto;
text-align: center;
}
#second_nav ul li{
margin: 0 auto;
display: inline-block;
}
#second_nav ul li img{
width: 80%;
}
Give #second_nav ul an explicit width. Without one, it's 100% of its parent (#second_nav), so there's no room either side to center it using margin: auto.
Try this:
#second_nav ul {
height: 215px;
width: 500px; /* or whatever you need... */
margin: 0 auto;
}
you only need to add the following rules
#second_nav ul {
width: 250px;
margin: 0 auto;
}
look at this example
You can check this:
#second_nav{
height: 255px;
width:100%;
text-align:center;
}
use text-align: center;
but ul need to be inline element "display:inline"
1 thing that I didn't tell. This is my normal second nav
/*second_nav*/
#second_nav{
background: url("images/second_nav.png");
height: 255px;
width: 100%;
}
#second_nav ul{
display: block;
margin: 0 0 0 170px;
width: 654px;
position: absolute;
padding: 25px 0 0 0;
}
#second_nav ul li{
display: block;
float: left;
margin: 0 0 0 60px;
height: 220px;
}
#second_nav ul li p{
font-size: 20px;
font-weight: 300;
color: #000000;
text-align: center;
width: 80px;
margin: 0 auto;
}
and this is my second_nav when screen is max- 820px i want to center this.
#second_nav{
height: 255px;
width:100%;.
margin: 0 auto;
}
#second_nav ul{
height: 215px;
margin: 0 auto;
text-align: center;
}
#second_nav ul li{
margin: 0 auto;
display: inline-block;
}
#second_nav ul li img{
width: 80%;
}
Related
Is possible to scale SVG using CSS? I use <img> to insert an SVG icon in HTML. Here is my code: http://jsfiddle.net/kw5fuw7L/.
nav {
width: 100%;
background: #202125;
box-shadow: 0px 1px 0px 0px #2C2E32;
padding: 0;
overflow: hidden;
}
nav ul {
list-style: none;
overflow: hidden;
margin: 0;
padding: 0;
}
nav ul li {
float: left;
position: relative;
padding: 20px 0;
width: 120px;
text-align: center;
}
nav ul li.active {
background: #F5A623;
}
svg path {
fill: #fff !important;
}
nav ul li .svg-container {
width: 20px;
height: 10px;
margin: 0 auto;
padding: 0 auto;
}
nav ul li img {
display: block;
margin: 0 auto;
padding: 0 auto;
width: 100%;
}
nav ul li span {
display: inline-block;
color: #fff;
padding-top: 10px;
}
nav ul li a {
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 120px;
text-indent: -5000em;
}
Unfortunately, I have to use this code too: http://jsfiddle.net/praveenscience/wuSF7/, to give them color. It works okay before I put there this script.
I would be grateful if someone have idea how to scale an SVG icons.
I have a footer which I am currently building.
I want to be able to center the 4 divs in the footer (like first paragraph or the 5 icons (which have failed to render)). What is the best way to do this?
Demo: http://jsfiddle.net/8q5ek/3/
CSS:
#insidefooter, #disclaimer {
max-width: 960px;
min-width: 960px;
margin-left: 25%;
margin-right: auto;
}
#footer {
color: #C9C9C9;
min-width: 1500px;
background-color: #2d2d2d;
list-style: none;
height: 450px;
background-image:url(http://i.imgur.com/yb7j6PD.png);
background-repeat:repeat;
}
#insidefooter {
margin-top: 20px;
text-align: center;
}
/*settings for social media buttons*/
#insidefootertermsplusbuttons li {
display: inline;
color: #C9C9C9;
}
#insidefooterone1 h5, #insidefootertwo1 h5, #insidefooterthree1 h5, #insidefooterfour1 h5 {
text-align:left;
margin-bottom: 0;
padding-bottom: 0;
color:#FFFFFF;
padding-left: 0px;
}
#insidefooterone1 li, #insidefootertwo1 li, #insidefooterthree1 li, #insidefooterfour1 li {
list-style: none;
text-align: left;
margin-left: 0;
color: #C9C9C9;
padding: 0;
}
#insidefooterone1 ul, #insidefootertwo1 ul, #insidefooterthree1 ul, #insidefooterfour1 ul {
list-style: none;
text-align: left;
padding-left: 0px;
padding-right: 0;
color: #C9C9C9;
overflow: hidden;
}
#disclaimer {
margin-top: 20px;
font-size: 9px;
text-align: center;
margin-bottom: 0;
}
#disclaimer p {
text-align:center;
color: #C9C9C9;
}
.ul_links {
overflow: auto;
display: inline-block;
min-width: 700px;
}
I solved your problem.
So I played around with your code a lot, did many changes, here is the result:
http://jsfiddle.net/rYjS9/7/
The actual trick was using display: inline-block; and margin-left: auto; margin-right: auto; and a couple of other stuff I have changed, as you can see from the jsfiddle. ;)
Regards
demo
remove
/* #insidefooter, #disclaimer {
max-width: 960px;
min-width: 960px;
margin-left: 25%;
margin-right: auto;
}*/
Add #footer in
margin 0 auto;
#footer {
color: #C9C9C9;
min-width: 1500px;
background-color: #2d2d2d;
list-style: none;
height: 450px;
background-image:url(http://i.imgur.com/yb7j6PD.png);
background-repeat:repeat;
margin 0 auto;
}
Remove below code and
#insidefooter, #disclaimer {
max-width: 960px;
min-width: 960px;
margin-left: 25%;
margin-right: auto;
}
Paste below code
#insidefooter, #disclaimer {
max-width: 960px;
min-width: 960px;
margin 0 auto;
}
Managed to figure it out. Thank you for your time and answers, but unfortunately, all of them failed to resolve to issue due to using a grid system (which was causing footer to distort).
What I needed to do was change the ul-links adding a position: relative and manually specifying it's position:
.ul_links{
overflow: auto;
display: inline-block;
min-width: 700px;
position: relative;
left: 120px;
}
It's probably not the best nor tidiest way to do it, but it solved the issue.
Demo
Hello I'm having a problem with my layout, when I'm resizing it, it's not filling the whole space. Please check it out here
My sample code:
html, body {
margin: 0;
padding: 0;
height: 100%;
}
p, a, h1 {
font-family: "Trebuchet MS", Helvetica, sans-serif;
}
.container {
width: 100%;
min-height: 100%;
position: relative;
}
.content {
width: 96%;
max-width: 720px;
min-width: 600px;
margin: 0 auto;
padding: 10px;
padding-bottom: 245px; /* Height of the footer element */
}
.headerWrapper {
position: absolute;
height: 85px;
background: #19A347;
z-index: 9000;
width: 100%;
}
#header {
width: 960px;
margin: 0 auto;
position: relative;
}
.logo {
position: absolute;
}
.logoimg {
display: block;
width: 155px;
height: 85px;
text-indent: -9999px;
}
.globalnav {
float: right;
clear: right;
padding: 8px 8px 0 0;
display: block;
}
.nav-menu {
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
.nav-menu li {
display: inline;
}
.nav-menu a {
display: inline-block;
padding: 15px;
margin: 5px;
color: #fff;
font-size: 20px;
text-decoration: none;
}
.nav-menu a:hover {
color: #66C285;
}
#footer {
height: 245px;
background: #1c1c1c;
position: absolute;
bottom:0;
left:0;
width: 100%;
}
.cols-container {
margin: 0 auto;
max-width: 960px;
min-width: 900px;
overflow: hidden;
}
.cols-container div {
width: 20%;
float: left;
padding: 5px;
margin: 15px;
}
.heading {
font-size: 20px;
color: #fff;
background: #009933;
padding: 5px 0 5px 10px;
}
#footer li, a {
color: #fff;
text-decoration: none;
}
#footer a:hover {
color: #999;
};
I don't know what's making it act like this way. Help is truly appreciated.
You should change the width between header and headerWrapper:
.headerWrapper {
position: absolute;
height: 85px;
background: #19A347;
z-index: 9000;
width: 960px;
}
#header {
width: 100%;
margin: 0 auto;
position: relative;
}
You also should change these rules:
.cols-container {
margin: 0 auto;
max-width: 960px;
min-width: 900px;
overflow: hidden;
}
.content {
width: 96%;
max-width: 720px;
min-width: 600px;
margin: 0 auto;
padding: 10px;
padding-bottom: 245px; /* Height of the footer element */
}
to the min-width you want:
.cols-container {
margin: 0 auto;
max-width: 960px;
min-width: 400px;
overflow: hidden;
}
.content {
width: 96%;
max-width: 720px;
min-width: 400px;
margin: 0 auto;
padding: 10px;
padding-bottom: 245px; /* Height of the footer element */
}
JSFIDDLE
Trying to have my buttons centered above the text below. I think it has to do with my float lefts, but i believe i need to still float it left because the content afterwards is also floating.
Margin: 0 auto; isnt working.
Please Advise:
.button {
background-color: rgb(214,52,49);
padding: 4px 24px;
border-radius: 40px 40px 40px 40px;
color: white;
text-decoration: none;
vertical-align: middle;
text-align: center;
font-size: 2rem;
display: block;
width: 150px; /* 150 / 980 */
}
nav {
width: 100%;
float: left;
margin: 0 0 1em 0;
padding: 0;
background-color: green;
border-bottom: 1px solid #ccc;
text-align: center;
vertical-align: text-top;
}
nav a.button {
float: left;
margin: 0 auto;
}
nav a.button:not(:first-child) {
margin-left: 150px;
}
http://jsfiddle.net/117sparten/kNZEs/3/
Here you go.
<header>
<nav>
<div class="btngroup">
contact
blog
</div>
</nav>
</header>
.button {
background-color: rgb(214,52,49);
padding: 4px 24px;
border-radius: 40px 40px 40px 40px;
color: white;
text-decoration: none;
text-align: center;
font-size: 2rem;
display: inline-block;
width: 150px; /* 150 / 980 */
}
.button:not(:first-of-type) {
margin-left: 10px;
}
nav {
width: 100%;
float: left;
margin: 0 0 1em 0;
padding: 0;
background-color: green;
border-bottom: 1px solid #ccc;
text-align: center;
vertical-align: text-top;
}
nav div.btngroup {
width: 410px;
margin: auto;
height:
}
nav a.button {
float: left;
margin: 0 auto;
}
Try change nav a.button like this:
nav a.button {
display: inline-block;
margin: 0 auto;
}
or
nav a.button {
display: inline;
margin: 0 auto;
}
use this inline-block property in button class
.button
{
display:inline-block;
}
and remove float property from nav a.button
I'm having problems aligning two elements. I wish to align the pagination in the middle of the navigational arrows for my two mini content sliders.
Design example of what I require:
http://www.garyrevell.co.uk/student-i/PastedGraphic-8.png
The current WIP in progress live site - http://www.garyrevell.co.uk/student-i/index.html
The CSS
#slider1 { height: 1%; overflow:hidden; padding: 0 0 0 0; }
#slider1 .viewport { float: left; width: 240px; min-height: 190px; overflow: hidden; position: relative; }
#slider1 .buttons { background:url("../images/buttons.png") no-repeat scroll 0 0 transparent; display: inline-block; background-position: 0 -38px; text-indent: -999em; float: left; width: 39px; height: 24px; overflow: hidden; position: relative; }
#slider1 .previous { background-position: 0 0; margin-left:5px; }
#slider1 .next { background-position: 0 0; left: 130px }
#slider1 .disable { visibility: hidden; }
#slider1 .overview { list-style: none; position: absolute; padding: 0; margin: 0; width: 240px; left: 0 top: 0; }
#slider1 .overview li{ float: left; margin: 0 20px 0 0; padding: 1px; width: 230px;}
/* Tiny Carousel - Slider Bullets */
#slider1 .pager, #slider2 .pager { overflow:hidden; list-style: none; clear: top; margin: 0 0 0 45px; }
/*Normal Style*/
#slider1 .pager li, #slider2 .pager li{ float: left; display: block;
}
#slider1 .pager a, #slider2 .pager a { width: 15px;
height: 12px;
width: 12px;
background:url(../images/bullet-norm.png); background-position: left top; background-repeat:no-repeat;
float: left;
text-indent: -4000px;
position: relative;
margin-left: 3px;
color: transparent;
display:inline-block;
cursor: pointer;
}
#slider1 .pager a:hover{
background-position: 0 50%;
}
#slider1 .pager .active {
color: #fff; background-image: url(../images/bullet-selected.png); } /*CURRENT IMAGE HERE*/
#slider1 .overview { list-style: none; position: absolute; width: 240px; left: 0 top: 0; }
#slider1 .overview li{ float: left; margin: 0 20px 0 0; width: 236px;
}
a.pagenum {margin-top: 12px;}
ul{border:0; margin:0; padding:0;}
Any help would be greatly appreciated.
set
ul.pager{
margin: 0 auto;
display: table; (ife the first line above alone did not work...)
}
Place this code after any of your other .pager referenced code
Also, remove any padding on the .pager class
Please update your css with mine css you will achieve your desired result :-
CSS
#slider1 .pager, #slider2 .pager {
list-style: none outside none;
margin: 0 0 0 45px;
overflow: hidden;
position: relative;
top: -23px;
}
Float left & right respectively the navigational arrows and remove left: 130px; from the second one.
Set equal left & right margin on ul.pager, set text-align: center on it and give its li display:inline-block
You can even align the pagination to be centered
CSS:
.pager-wrapper{
padding: 5px;
height: 23px;
width: something;
float: left;
text-align: center;
}
a {
padding: 10px;
margin: 4px;
border: 1px solid black;
text-decoration: none;
font-size: 1px;
}
a:hover {
background: red;
color: white;
}
.selected {
background: red;
color: white;
}
HTML:
<div class="pager-wrapper" >
<a class="selected" href="#">1</a>234
</div>