Everything else on the page expands or shrinks as the page is resized, except the list that makes up the nav. What am I doing wrong? It's as though the first item is anchored to the left.
codepen: http://codepen.io/kiddigit/pen/mEPENJ?editors=1100
<header>
<img src="images/m_and_m_logo.png" />
<ul id="nav">
<li>Gift Baskets and Catering</li>
<li>Tasting Calendar</li>
<li>Membership</li>
<li>Special Events</li>
</ul>
</header>
*{
width:100%;
border:0px solid black;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
header {
width: 100%;
margin: 0 auto;
}
#nav, li {
display: inline;
margin-right: 10%;
}
header img {
width: 50%;
display: block;
margin: 0 auto;
}
footer li {
padding: 15px;
margin-top: 100px;
display: inline;
}
.social_icons {
width: 5%;
margin: 20px;
}
#body {
padding-top: 20px;
padding-bottom: 20px;
width: 90%;
margin: 0 auto;
height: 900px;
}
#box_left {
float: left;
width: 48%;
height: 100%;
}
#box_left, p {
text-align: center;
}
#box_right {
float: right;
width: 48%;
height: 100%;
}
#box_right, p {
text-align: center;
}
#store {
font-size: 22px;
font-weight: 800;
}
footer {
text-align: center;
margin: 0 auto;
width: 90%;
height: 100px;
}
Not sure what you are after, but you might want to change this selector:
#nav, li {
display: inline;
margin-right: 10%;
}
to this:
#nav li {
display: inline;
margin-right: 10%;
}
(no comma after #nav- otherwise those settings apply both to #nav AND to all li elements on that page)
Related
In This Code,I want to set the margin-top of .Login class ,smaller,although I set The margin-top ,to zero,but it is not set near to the top of page.What Can I do?why by setting the margin-top of this division ,this div does not set ,near the top of page?is other thing ok?the other elements works properly.
body {
margin: 0px;
direction: rtl;
}
#font-face {
src: url('../fonts/IRANSansWeb.eot'), url('../fonts/IRANSansWeb.woff'), url('../fonts/IRANSansWeb.woff2'), url('../fonts/IRANSansWeb.ttf');
font-family: "IranSans";
}
header {
width: 100%;
min-height: 700px;
height: auto;
overflow: auto;
background-color: #007bff;
}
nav {
margin-top: 0px;
height: 50px;
}
nav ul {
width: 60%;
height: 60px;
margin: 0px auto;
border: 2px solid black;
display: inline-block;
}
.Logo {
width: 160px;
height: 50px;
margin-left: 0px;
margin-right: 30px;
margin-bottom: 0px;
display: inline-block;
}
.Logo img {
width: 100%;
height: 100%;
}
.LogIn {
width: 140px;
height: 50px;
display: inline-block;
margin-right: 130px;
margin-top: 0px;
font-family: "IranSans";
border-radius: 5px;
background-color: #00d363;
}
.LogInA {
width: 100%;
height: 100%;
border: 5px;
color: #fff;
display: inline-block;
text-decoration: none;
text-align: center;
line-height: 50px;
}
.LogInA:hover {
border-radius: 5px;
background-color: #007bff;
color: #00d363;
border: 1px solid #00d363;
}
<body>
<header>
<nav>
<div class="Logo"><img src="Content/img/logo.png" alt="جاب بورد"></div>
<ul>
</ul>
<div class="LogIn">
<a class="LogInA" href="#">ارسال شغل</a>
</div>
</nav>
</header>
</body>
Try adding display: flex; to your nav
You should use:
display:flex; justify-content: center; to your Nav and also you should remove height and use: flex-direction:column; in mobile version.
I am currently having an issue where my navigation bar and banner shrink when I set their position to fixed.I have many things like changing z-index,setting its top position to 0,adding auto margin etc, and none of it worked.I hope someone can point me to my mistake.This is my html code:
html,
body {
margin: 0;
background-color: #ffeecc;
font-family: 'Chivo', sans-serif;
}
.container {
margin: auto;
width: 75%;
}
.nav_left {
width: 100%;
background-color: #258e25;
height: 50px;
float: left;
text-align: left;
}
.banner {
width: 100%;
overflow: hidden;
background-color: white;
}
.banner img {
width: 70%;
height: 150px;
padding: 0 15%;
}
.top {
position: fixed;
}
nav {
text-align: center;
}
nav ul {
list-style-type: none;
padding: 0;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
nav ul li {
float: left;
text-align: center;
height: 100%;
width: 25%;
}
nav ul li a {
display: inline-block;
width: 100%;
font-weight: bold;
line-height: 50px;
text-decoration: none;
color: white;
}
nav ul li a:hover {
background-color: white;
color: black;
}
<div class="container">
<div class="top">
<div class="banner">
<img src="images/winwin-logo-cover.jpg" alt="winwin logo">
</div>
<nav>
<div class="nav_left">
<ul>
<li>PROIZVODI</li>
<li>O NAMA</li>
<li>KONTAKT</li>
</ul>
</div>
<div class="nav_right"></div>
</nav>
</div>
this is how it should look like
this is how it looks like when i put .top{position:fixed}
When you set an element to absolute or fixed position, it will be out of the the normal content flow and trigger the shrink to fit feature. You can apply the offsets and width/height to position and recreate the box size you wish to have.
.top {
position: fixed;
left: 0; /* ADDED */
top: 0; /* ADDED */
width: 100%; /* ADDED */
}
html,
body {
margin: 0;
background-color: #ffeecc;
font-family: 'Chivo', sans-serif;
}
.container {
margin: auto;
width: 75%;
}
.nav_left {
width: 100%;
background-color: #258e25;
height: 50px;
float: left;
text-align: left;
}
.banner {
width: 100%;
overflow: hidden;
background-color: white;
}
.banner img {
width: 70%;
height: 150px;
padding: 0 15%;
}
.top {
position: fixed;
left: 0;
top: 0;
width: 100%;
}
nav {
text-align: center;
}
nav ul {
list-style-type: none;
padding: 0;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
nav ul li {
float: left;
text-align: center;
height: 100%;
width: 25%;
}
nav ul li a {
display: inline-block;
width: 100%;
font-weight: bold;
line-height: 50px;
text-decoration: none;
color: white;
}
nav ul li a:hover {
background-color: white;
color: black;
}
<div class="container">
<div class="top">
<div class="banner">
<img src="images/winwin-logo-cover.jpg" alt="winwin logo">
</div>
<nav>
<div class="nav_left">
<ul>
<li>PROIZVODI</li>
<li>O NAMA</li>
<li>KONTAKT</li>
</ul>
</div>
<div class="nav_right"></div>
</nav>
</div>
Because .top has no width. However, when set to fixed it is using the viewport width to calculate the width. You might want to set it to 75%.
You also might want to set .container to position: relative so .top will relate to its borders.
body {
margin: 0;
background-color: #ffeecc;
font-family: 'Chivo', sans-serif;
}
.container {
margin: auto;
width: 75%;
position: relative;
}
.top {
position: fixed;
width: 75%;
}
.nav_left {
width: 100%;
background-color: #258e25;
height: 50px;
float: left;
text-align: left;
}
nav {
text-align: center;
}
nav ul {
list-style-type: none;
padding: 0;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
nav ul li {
float: left;
text-align: center;
height: 100%;
width: 25%;
}
nav ul li a {
display: inline-block;
width: 100%;
font-weight: bold;
line-height: 50px;
text-decoration: none;
color: white;
}
nav ul li a:hover {
background-color: white;
color: black;
}
<div class="container">
<div class="top">
<nav>
<div class="nav_left">
<ul>
<li>PROIZVODI</li>
<li>O NAMA</li>
<li>KONTAKT</li>
</ul>
</div>
<div class="nav_right"></div>
</nav>
</div>
Sorry bit of a newbie, but i'm having this annoying issue where I can't figure out why these two divs are overlapping... I have content behind the second pic that's being covered right now but I want that content to be shown and for the second pic to be displayed normally under it..
heres what I have html:
<main>
<div id="top_head">
<h2>
Gallery
</h2>
</div>
<br>
<div id="canvas">
<div class="gal_block">
<img src="../img/b_sign.jpg" alt="#">
<br>
<h2 class="gal_head">Chill Morning</h2>
<br>
<p class="gal_meta">May 12, 2018 / by nock / Outdoors<p>
<br>
<p class="gal_info"></p>
</div>
<div class="gal_block">
<img src="../img/b_sign.jpg" alt="#">
<br>
<h2 class="gal_head">Chill Morning</h2>
<br>
<p class="gal_meta">May 12, 2018 / by nock / Outdoors<p>
<br>
<p class="gal_info"></p>
</div>
</div>
</main>
And my css:
* {
margin:0;
padding: 0;
}
.clearfix {
clear: both;
}
#container {
margin: 0 auto;
width: 100%;
}
a {
text-decoration: none;
}
header {
width: 100%;
}
#left_header {
float: left;
margin: 5%;
padding:;
width: 20%
}
#left_header h1 {
font-family: 'Pacifico',cursive;
}
header nav {
float: right;
margin: 5%;
width: 35%;
}
header nav ul li {
float: left;
margin-left: 7%;
padding:0;
list-style: none;
font-size: 20px;
font-family: 'Raleway',cursive;
}
header nav ul li a {
color: black;
transition: color 1s;
}
header nav ul li a:hover {
color: gray;
}
main {
}
#top_head h2 {
font-family: 'Source Serif Pro';
font-size: 30px;
text-align: center;
}
/*affects all pages ^^^*/
/*home*/
#img_wall {
width: 82%;
height: 100%;
padding: 7%;
}
#l_big {
padding: 1%;
float: left;
width: 58%;
height: 67%;
}
#l_big img{
width: 100%;
height: 100%;
border-radius: 5px;
}
#r_top {
padding: 1%;
float: left;
width: 38%;
height: 32%;
}
#r_top img {
width: 100%;
height: 100%;
border-radius: 5px;
}
#r_bottom {
padding: 1%;
float: left;
width: 38%;
height: 32%;
}
#r_bottom img {
width: 100%;
height: 100%;
border-radius: 5px;
}
/*home end*/
/*about*/
/*about end*/
/*gallery*/
#canvas {
}
.gal_block {
display: block;
margin: 0 auto;
width: 80%;
height: 70%;
margin-top: 5%;
}
.gal_block img {
width: 100%;
height: 100%;
display: block;
margin: 0 auto;
border-radius: 5px;
}
.gal_head {
font-family: 'Source Serif Pro';
font-size: 25px;
text-align: center;
margin-top: 2%;
}
.gal_meta {
font-family: 'Raleway',cursive;
font-size: 12px;
color: gray;
text-align: center;
}
.gal_info {
font-size: 14px;
font-family: Arial;
width: 40%;
margin: 0 auto;
line-height: 1.5;
margin-bottom: 8%;
}
I also have a container over everything that with a width of 100% if that matters..(guessing it doesn't) but img of the issue below
if you look closely you can see the text thats supposed to be not cover..revealing itself when I mess with the zoom on the page...
Tried to vertically align my nav menu with my logo image but with the code I have the navbar doesn't even seem to be within the container element. Any specific error or is it multiple things?
/* Body styles */
body {
background-color: white;
margin: 0px;
width: 100%;
min-width: 1000px;
max-width: 1400px;
}
/* Header styles */
header {
background-color: white;
min-height: 140px;
height: 160px;
}
header img {
display: inline-block;
clear: left;
margin: 0;
}
/* Navigation list styles */
header .container {
margin: auto;
width: 1140px;
min-height: inherit;
height: inherit;
}
header .container .nav-logo {
min-height: inherit;
height: inherit;
width: 188px;
padding-top: 35px;
}
li {
list-style: none;
}
nav.nav-right {
min-width: 737.667px;
width: 737.667px;
float: right;
}
.nav-right ul {
display: inline-block;
margin-left: 40px;
padding: 0px;
vertical-align: top;
}
.nav-right li {
display: inline;
text-transform: uppercase;
font-family: sans-serif;
}
.nav-right li a {
display: inline-block;
color: black;
text-decoration: none;
padding: 5px 10px;
}
.nav-right li a:hover {
outline: 1px black solid;
margin: 0px;
}
<header>
<div class="container">
<div class="nav-logo">
<img src="site_logo.png" alt="Site Logo" />
</div>
<nav class="nav-right">
<ul>
<li>Menu</li>
<li>Locations</li>
<li>Nutrition</li>
<li><a href=# alt="our
story">Our Story</a></li>
<li>Rewards</li>
</ul>
</nav>
</div>
</header>
You needed to add a display: inline-block to your header .container .nav-logo
/* Body styles */
body {
background-color: white;
margin: 0px;
width: 100%;
min-width: 1000px;
max-width: 1400px;
}
/* Header styles */
header {
background-color: white;
min-height: 140px;
height: 160px;
}
header img {
display: inline-block;
clear: left;
margin: 0;
}
/* Navigation list styles */
header .container {
margin: auto;
width: 1140px;
min-height: inherit;
height: inherit;
}
header .container .nav-logo {
min-height: inherit;
height: inherit;
width: 188px;
padding-top: 35px;
display: inline-block;
}
li {
list-style: none;
}
nav.nav-right {
min-width: 737.667px;
width: 737.667px;
float: right;
}
.nav-right ul {
display: inline-block;
margin-left: 40px;
padding: 0px;
vertical-align: top;
}
.nav-right li {
display: inline;
text-transform: uppercase;
font-family: sans-serif;
}
.nav-right li a {
display: inline-block;
color: black;
text-decoration: none;
padding: 5px 10px;
}
.nav-right li a:hover {
outline: 1px black solid;
margin: 0px;
}
<header>
<div class="container">
<div class="nav-logo">
<img src="site_logo.png" alt="Site Logo" />
</div>
<nav class="nav-right">
<ul>
<li>Menu</li>
<li>Locations</li>
<li>Nutrition</li>
<li>Our Story</li>
<li>Rewards</li>
</ul>
</nav>
</div>
</header>
Just add a new css rule display: inline; for .nav-logo{};
Working codepen: https://codepen.io/Omi236/pen/YQdKZY
Whether or not it's the best practice, you can simply add float: left; to header .container .nav-logo
header .container .nav-logo {
min-height: inherit;
height: inherit;
width: 188px;
padding-top: 35px;
float: left;
}
https://jsfiddle.net/vu8y4uxa/
Or as suggested elsewhere use display: inline-block;
You can try this code :
/* Body styles */
body {
background-color: white;
margin: 0px;
width: 100%;
min-width: 1000px;
max-width: 1400px;
}
/* Header styles */
header {
background-color: white;
min-height: 140px;
height: 160px;
}
header img {
display: inline-block;
clear: left;
margin: 0;
}
/* Navigation list styles */
header .container {
margin: auto;
width: 1140px;
min-height: inherit;
height: inherit;
}
header .container .nav-logo {
min-height: inherit;
height: inherit;
width: 188px;
padding-top: 35px;
display: inline-block;//Add this
}
li {
list-style: none;
}
nav.nav-right {
min-width: 737.667px;
/*width: 737.667px;*///Remove this
/*float: right;*///Remove this
}
.nav-right ul {
display: inline-block;
margin-left: 40px;
padding: 0px;
vertical-align: top;
}
.nav-right li {
display: inline;
text-transform: uppercase;
font-family: sans-serif;
}
.nav-right li a {
display: inline-block;
color: black;
text-decoration: none;
padding: 5px 10px;
}
.nav-right li a:hover {
outline: 1px black solid;
margin: 0px;
}
<header>
<div class="container">
<nav class="nav-right">
<div class="nav-logo"><!--Move this-->
<img src="site_logo.png" alt="Site Logo" />
</div>
<ul>
<li>Menu</li>
<li>Locations</li>
<li>Nutrition</li>
<li><a href=# alt="our
story">Our Story</a></li>
<li>Rewards</li>
</ul>
</nav>
</div>
</header>
An option is to use flexbox, which will also save you some CSS coding. For browser compatibility please check here. The code suggested doesn't give any issues from IE11 onwards.
.container {
display: flex;
align-items: center;
}
ul {
padding: 0;
margin: 0;
list-style: none;
display: flex;
}
ul li {
padding: 1em;
text-transform: uppercase;
font-family: sans-serif;
}
ul li a {
text-decoration: none;
color: black;
}
<header>
<div class="container">
<div class="nav-logo">
<img src="http://placehold.it/100&text=LOGO" alt="Site Logo" />
</div>
<nav class="nav-right">
<ul>
<li>Menu</li>
<li>Locations</li>
<li>Nutrition</li>
<li>Our Story</li>
<li>Rewards</li>
</ul>
</nav>
</div>
</header>
It's not hard, you use float: right; for nav-right but you forgot to use float: left; for nav-logo class. This will fix it!
I am not sure but you can try inserting your image source line nav-right class,
as i don't see the css code for nav-logo class, else write the code for nav-logo class
.nav-logo {
display: inline-block;
vertical-align: right;
max-width:100%; // or your desired size
}
How to justify all images inside a div so that there is no any space left in the left-side and the right-side of the div.
Here is my HTML:
<ul class="thumnails">
<li class="img-thum">
<img src="broward.jpg"/>
<p class="thum-capt">How a Squad of Ex-Cops Fights Police Abuses</p>
</li>
<li class="img-thum">
<img src="honey.jpg"/>
<p class="thum-capt">The Men's Rights Movement and the Women Who Love It</p>
</li>
<li class="img-thum">
<img src="bottles.jpg"/>
<p class="thum-capt">Bottled Water Comes From the Most Drought-Ridden Places in the Country</p>
</li>
<li class="img-thum">
<img src="snyder.jpg"/>
<p class="thum-capt">6 Dumb Things Dan Snyder Has Said About the Name of His Football Team</p>
</li>
</ul>
And here my CSS
If I am setting the padding-right with value, then there will be a space in the right-side.
.thumnails {
width: 100%;
display: block;
float: left;
overflow: hidden;
padding: 0;
margin: 12px auto;
position: relative;
list-style: none;
}
.thumnails .img-thum {
width: 23%;
display: inline-block;
padding: 0;
padding-right: 1.5%;
margin: 0 auto;
}
.thumnails .img-thum img {
width: 100%;
padding: 0;
margin: 0;
}
.thumnails .img-thum .thum-capt {
width: 100%;
float: left;
overflow: hidden;
display: block;
position: relative;
padding: 0;
margin: 0;
font-weight: bold;
font-size: 14px;
font-family: serif;
}
My Fiddle
Try to read this article by Chris Coyer:
http://css-tricks.com/equidistant-objects-with-css/
Your css should be like this:
.thumnails {
width: 100%;
display: block;
float: left;
overflow: hidden;
padding: 0;
margin: 12px auto;
position: relative;
list-style: none;
text-align: justify; /* <== add this */
}
.thumnails .img-thum {
width: 23%;
display: inline-block;
padding: 0;
margin: 0 auto;
}
.thumnails .img-thum img {
display: inline-block; /* <== and this */
width: 100%;
padding: 0;
margin: 0;
}
.thumnails .img-thum .thum-capt {
width: 100%;
float: left;
overflow: hidden;
display: block;
position: relative;
padding: 0;
margin: 0;
font-weight: bold;
font-size: 14px;
font-family: serif;
}
/*and this*/
.thumnails:after {
content: '';
width: 100%; /* Ensures there are at least 2 lines of text, so justification works */
display: inline-block;
}
please see this demo
To ensure proper sizing it's nearly always worth using box-sizing:border-box so that padding and borders are included in width calculations.
Then the are two simple methods (based on your current code) although there are other options available.
JSfiddle (Inline-block)
Jsfiddle (Floats)
CSS re Inline Block
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.thumnails {
width: 100%;
display: block;
float: left;
overflow: hidden;
padding: 0;
margin: 12px auto;
position: relative;
list-style: none;
background:black;
font-size:0; /* required to remove white space */
}
.thumnails .img-thum {
width: 25%;
display: inline-block; /* change to float:left for float version */
padding: 0;
margin: 0 auto;
}
.thumnails .img-thum img {
width: 100%;
padding: 0;
margin: 0;
}
.thumnails .img-thum .thum-capt {
width: 100%;
float: left;
overflow: hidden;
display: block;
position: relative;
padding: 0;
margin: 0;
font-weight: bold;
font-size: 14px;
font-family: serif;
}
try like this: Demo
Just update this css to solve this problem.
CSS:
.thumnails .img-thum {
width: 23%;
display: inline-block;
padding: 0;
margin: 0;
float:left;
}
Updated fiddle Link
Space between images: Link. Hope you need like this
Solved Your Problem >> Images Without Space and justified in middle
Test in Full Screen >> FullScreen Fiddle
Modified css
.thumnails {
width: 100%;
display: block;
float: left;
overflow: hidden;
padding: 0;
margin:1%;
position: relative;
list-style: none;
white-space:no-wrap;
}
.thumnails .img-thum {
width: 22.5%;
display: inline-block;
padding: 1%;
margin: 0 auto;
}
.thumnails .img-thum img {
width: 100%;
padding: 0;
margin: 0;
}
.thumnails .img-thum .thum-capt {
width: 100%;
float: left;
overflow: hidden;
display: block;
position: relative;
padding: 0;
margin: 0;
font-weight: bold;
font-size: 14px;
font-family: serif;
}