I'm building a website on Github page and I am trying to change color of footer.
As you can see, I made with class "footer" .
On CSS, I put background-color property and set as #000000.
But, I still can't see background color with black on desktop.( I can see on mobile page because I set media query)
The Code is below.
#media screen and (min-width: 1000px) {
html, body{
font-family: "Comfortaa";
}
.header-logo{
float: left;
padding: 10px 30px;
}
.header li:hover{
border-bottom: 2px solid #24ABE2;
}
.header a{
float:left;
display:block;
color:black;
}
.header-link li{
float: left;
padding: 5px 60px;
font-size: 20px;
color:#24ABE2;
}
/* Dropdown Button */
.droplist{
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: white;
min-width: 240px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 20;
margin-top: 29px;
height: 210px;
color:#24ABE2;
}
/* Links inside the dropdown */
.dropdown-content a {
color: #24ABE2;
padding: 12px 16px;
text-decoration: none;
display: block;
z-index: 20;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
border-bottom: 2px solid #24ABE2;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: white;
}
.footer-logo{
float: left;
padding: 15px 20px;
width: 300px;
height: auto;
margin-left: 30px;
margin-top: 20px;
}
.footer-list{
margin-top:10px;
font-size: 20px;
color: #ccfbff;
float: right;
padding: 2px 8px;
margin-right: 40px;
}
.footer-list li{
padding: 10px;
}
}
#media screen and (max-width: 1000px) {
html, body{
font-family: Nunito;
}
.header-logo{
text-align:center;
margin-left:20px;
padding: 10px 30px;
}
.header li{
display:none;
}
.header-link{
display:none;
}
.footer-logo{
padding: 15px 10px;
width: 300px;
height: 90px;
margin:auto;
text-align:center;
}
.footer-logo img{
width: 300px;
height: auto;
margin:auto;
text-align:center;
}
.footer-list{
display:block;
margin:auto;
font-size: 20px;
color: #ccfbff;
padding: 2px 8px;
text-align:center;
}
.footer-list li{
margin:auto;
padding: 5px;
font-size:20px;
text-align:center;
}
}
/* CSS for default design */
html { scroll-behavior: smooth; }
html, body{
height: 100%;
width: 100%;
margin: 0px 0px 0px 0px;
z-index:-10;
}
/* Settings of a tag for whole page*/
a:link {
text-decoration: none;
cursor: pointer;
}
a:visited {
text-decoration: none;
cursor: pointer;
}
a:hover {
text-decoration: none;
cursor: pointer;
}
a:active {
text-decoration: none;
cursor: pointer;
}
.header {
border-bottom:2px solid #0E76BC;
background-color: white;
height: 60px;
position: fixed;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
opacity: 90%;
margin: 0px 0px 0px 0px;
z-index:10;
}
.header-logo{
width: 300px;
height: auto;
}
li{
list-style: none;
}
.footer{
height: auto;
background-color: #000000 !important;
width: 100%;
margin: 0px 0px 0px 0px;
}
.footer a:link {
color: #ccfbff;
}
.footer a:visited {
color: #ccfbff;
}
.footer a:hover {
color: #ccfbff;
}
.footer a:active {
color: #ccfbff;
}
<div class="footer">
<img src="https://i.ibb.co/p4LvvdH/Copy-of-LOGO-White.png" alt="SLED Logo" class="footer-logo" />
<div class="footer-list">
<ul>
<li>Back to Top</li>
<li>Instagram</li>
<li>Facebook</li>
<li>Jcbms-sled-team#mail.fcboe.org</li>
<li>J.C. Booth Middle School</li>
<li>Fayette County Public Schools</li>
</ul>
</div>
</div>
Whenever we give float property on child item then parents give automatically own height to 0, so please put it:
.footer:before,
.footer:after
{
clear: both;
display: block;
content: '';
}
The reason is because you set your footer height to auto without defining a minimum height. To solve this just put min-height: 50vh; to your .footer class. Of course you can change 50vh to whatever minimum height you want.
try something like this
.footer
{
min-height: 100%;
background-color: #000000 !important;
width: 100%;
margin: 0px 0px 0px 0px;
}
set min-height: 100% instead of height:auto from .footer class
Related
The sign is forcing the buttons to move down. I don't want this, as I want the sign to be in the right side of the screen. if you see the result, the buttons are under the sign. How do I avoid this. Absolute and relative positioning doesn't work because it just makes the elements overlap. I also want this to work for other elements when. I put them in. Thanks.
:root {
--gray: #343434;
--purple: #5e5ebe;
--blue: #3495d9;
--red: #ff3a41;
}
.header-right{
border-radius: 30px;
background: var(--red);
color:rgb(3, 2, 2);
padding: 20px;
width: 200px;
height: 20px;
text-align: center;
width:500px;
margin:50px ;
}
.sign{
border-radius: 25px;
background: red;
padding: 20px;
width: 200px;
height: 20px;
top:100px;
}
#navbar{
background: var(--gray);
height: 51px;
padding: 0;
margin: 0;
border-radius: 0px;
width: 100%;
display: flex;
}
*{
padding:0;
margin:0;
}
#navbar ul, #navbar li {
margin: 0 auto;
padding: 0;
list-style: none
}
#navbar li {
float: left;
}
/*#navbar span {
display: flex;
width: fit-content;
}*/
.centered{
margin: auto;
}
#navbar a {
display: inline-block;
display:flex;
line-height: 51px;
padding: 0 14px;
text-decoration: none;
color: #FFFFFF;
font-size: 16px;
}
#navbar li a:hover {
color: #0099CC;
background: #F2F2F2;
}
<nav id='navbar'>
<ul>
<p class="sign">Sign</p>
<li class="centered"><a href='#'>Home</a></li>
<li class="centered"><a href='#'>Updates</a></li>
<li class="centered"><a href='#'>Who am I?</a></li>
</ul>
</nav>
Is This The Result You Wanted ? Code has been updated.
:root {
--gray: #343434;
--purple: #5e5ebe;
--blue: #3495d9;
--red: #ff3a41;
}
.header-right{
border-radius: 30px;
background: var(--red);
color:rgb(3, 2, 2);
padding: 20px;
width: 200px;
height: 20px;
text-align: center;
width:500px;
margin:50px ;
}
.sign{
border-radius: 25px;
float:right;
background: red;
padding: 15px;
width: 200px;
height: 20px;
position:absolute;
right:0;
}
#navbar{
background: var(--gray);
height: 50px;
padding: 0;
margin: 0;
border-radius: 0px;
width: 100%;
display: flex;
}
*{
padding:0;
margin:0;
}
#navbar ul, #navbar li {
margin: 0 auto;
padding: 0;
list-style: none
}
#navbar li {
float: left;
}
/*#navbar span {
display: flex;
width: fit-content;
}*/
.centered{
margin: auto;
}
#navbar a {
display: inline-block;
display:flex;
line-height: 51px;
padding: 0 14px;
text-decoration: none;
color: #FFFFFF;
font-size: 16px;
}
#navbar li a:hover {
color: #0099CC;
background: #F2F2F2;
}
#media screen and (max-width: 700px) {
#navbar ul {
margin:0;
}
}
<nav id='navbar'>
<ul>
<p class="sign">Sign</p>
<li class="centered"><a href='#'>Home</a></li>
<li class="centered"><a href='#'>Updates</a></li>
<li class="centered"><a href='#'>Who am I?</a></li>
</ul>
</nav>
I'm trying to make a dropdown menu on the right side of the screen for my users. But it keeps getting cut off and is hiding my text.
When I hover over my dropdown, it gets completely cut off and hides my welcome text on the screen.
My HTML Markup:
<header>
<div>
<?php
if (isset($_SESSION['userId'])) {
require './includes/dbh.inc.php';
/*$sql = mysqli_query($conn,"SELECT fnidUser, lnidUsers FROM users"); */
$result = mysqli_query($conn, "SELECT fnidUser FROM users");
echo "
<div class='dropdown' style='float:right;'>
<li class='login current2'><a href='#'>Welcome</a>
<div class='dropdown-content'>
<ul>
<li style='font-size:25px;'><a href='#'>My Account</a></la>
<li style='font-size:25px;'><a href='#'>My Orders</a></la>
<li style='font-size:25px;'><a href='#'>My Wishlist</a></la>
<li style='font-size:25px;'><a href='#'>My Cart</a></la>
<li style='font-size:25px;'><a href='#'>Log out</a></la>
</ul>
</div>
</li>
</div>
";
}
else{
echo "<li class='login current2'><a href='login.php'>Login / Sign up</a></li>";
}
?>
</div>
<div class="container">
<div id="branding">
<h1><img src="./Header Image/header.png"></h1>
</div>
<nav>
<ul>
<li>Home</li>
<li>Apple</li>
<li>Samsung</li>
<li>Gadgets</li>
</ul>
</nav>
</div>
</header>
My CSS Style for this page(side note, I attempted to make the text size smaller and for some reason it doesn't seem to work):
/* Global */
.container{
width: 80%;
margin: auto;
overflow: hidden;
}
ul{
margin: 0;
padding: 0;
}
.button_1 {
height: 49px;
width: 144px;
background: #FF3B3F;
border: 0;
padding-left: 20px;
padding-right: 20px;
color: white;
font-size: 25px;
border-radius: 8px;
cursor: pointer;
}
.button_1:hover{
background-color: #752021;
color: #CCCCCC;
}
.button_1, .roundbutton:focus{
outline: 0;
}
img{
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none;
}
body{
font: 15px/1.5 Arial;
padding: 0;
margin: 0;
background-color: #EFEFEF;
}
.footerc{
float: left;
}
.footerb{
float: right;
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Login Page Stuff */
#login_page{
margin-top: 65px;
margin-right: 150px;
margin-bottom: 65px;
margin-left: 150px;
min-height: 500px;
}
#login_page h1{
text-align: center;
color: #FF3B3F;
font-size: 50px;
text-shadow: 2px 2px 12px #000000;
}
/* Header */
header{
background: #35424A;
color: #FFFFFF;
padding-top: 30px;
min-height: 70px;
border-bottom: #FF3B3F 5px solid;
}
header ul a{
color: #FFFFFF;
text-decoration: none;
text-transform: uppercase;
font-size: 24px;
}
header li{
float: left;
display: inline;
padding: 0px 20px 0px 20px;
}
header #branding{
float: left;
}
header #branding h1{
margin: 0;
}
header nav{
float: right;
margin-top: 25px;
margin-right: 100px;
}
header .highlight, header .current a{
color: #FF3B3F;
font-weight: bold;
}
header .current2 a{
color: #FF3B3F;
}
header a:hover{
color: #CCCCCC;
}
.login a{
color: #FFFFFF;
text-decoration: none;
float: right;
}
.login {
color: #FFFFFF;
text-decoration: none;
float: right;
margin-top: -10px;
margin-right: 10px;
}
/* Login Form Style */
section #login_page td .form{
margin-bottom: 25px;
}
/*Showcase*/
#showcase{
min-height: 500px;
background:url('../img/iphone_showcase.png') no-repeat -50px -50px;
border-bottom: #FF3B3F 5px solid;
/*Scroll Parallax*/
background-attachment: fixed;
}
#showcase h1{
text-align: center;
color: #FF3B3F;
margin-top: 200px;
font-size: 50px;
text-shadow: 4px 4px 12px #000000;
}
/* Boxes */
#boxes{
margin-top: 65px;
}
#boxes .box{
float: left;
width: 30%;
padding: 25px;
}
#boxes .button_1{
align-content: center;
}
#boxes .box2{
float: left;
width: 48%;
min-height: 100px;
}
/* Footer */
footer{
padding: 20px;
margin-top: 200px;
border-top: #FF3B3F 5px solid;
background-color: #35424A;
color: white;
font-weight: bold;
}
footer .fpara, footer .logo{
margin-left: 100px;
}
footer nav{
float: right;
}
footer li{
float: left;
display: inline;
padding: 0px 20px 0px 20px;
}
.fbhover{
background: url('../footer image/facebook_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.fbhover:hover{
background: url('../footer image/facebook_hover_yes.png') no-repeat;
background-size: 100%;
}
.instahover{
background: url('../footer image/insta_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.instahover:hover{
background: url('../footer image/insta_hover_yes.png') no-repeat;
background-size: 100%;
}
.trhover{
background: url('../footer image/twitter_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.trhover:hover{
background: url('../footer image/twitter_hover_yes.png') no-repeat;
background-size: 100%;
}
.sphover{
background: url('../footer image/support_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.sphover:hover{
background: url('../footer image/support_hover_yes.png') no-repeat;
background-size: 100%;
}
/* Apple Store */
section #applestore{
margin-top: 65px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Store Sections */
#main {
padding:20px 0;
}
#content {
overflow: hidden;
}
#content #left, #content #right {
float: left;
margin: 0 2%;
width: 63%;
}
#content #right {
margin-left: 0;
width: 30%;
}
#content h3 {
background: -moz-linear-gradient(#ffffff, #F6F6F6); /* FF 3.6+ */
background: -ms-linear-gradient(#ffffff, #F6F6F6); /* IE10 */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #F6F6F6)); /* Safari 4+, Chrome 2+ */
background: -webkit-linear-gradient(#ffffff, #F6F6F6); /* Safari 5.1+, Chrome 10+ */
background: -o-linear-gradient(#ffffff, #F6F6F6); /* Opera 11.10 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#F6F6F6'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#F6F6F6')"; /* IE8+ */
background: linear-gradient(#ffffff, #F6F6F6); /* the standard */
border-bottom: 1px solid #E0E0E0;
color: #3C3C3C;
font-size: 12px;
font-weight: bold;
line-height: 15px;
padding: 11px 0 12px 20px;
text-transform: uppercase;
}
#content ul {
list-style:none outside none;
margin:0;
padding:0;
}
#content #left ul li {
float:left;
padding-bottom: 21px;
width: 33%;
}
#content #left ul li:hover {
background-color: #fbfbfb;
}
#content #right ul li {
border-top: 1px solid #E7E7E7;
overflow: hidden;
}
#content #right ul li:hover {
background-color: #fbfbfb;
}
#content #right ul li:first-child {
border-width: none;
}
#content #left ul li .img {
text-align: center;
}
#content #right ul li .img {
background-color: #FFFFFF;
float: left;
height: 94px;
text-align: center;
width: 113px;
}
#content #left ul li .img img {
height:128px;
width:128px;
}
#content #right ul li .img img {
height:70px;
margin-top: 11px;
width:70px;
}
#content #left ul li .info {
padding: 17px 20px 0 19px;
}
#content #right ul li .info {
float: left;
overflow: hidden;
padding: 17px 0 0 21px;
width: 164px;
}
#content ul li .info .title {
color: #4B4B4B;
display: inline-block;
font-size: 11px;
font-weight: bold;
line-height: 16px;
text-decoration: none;
text-transform: uppercase;
width: 150px;
}
#content ul li .info .title:hover {
color: #049733;
}
#content #left ul li .info p {
color: #7F7F7F;
font-size: 11px;
line-height: 16px;
padding-top: 3px;
}
#content #left ul li .info .price {
background: none repeat scroll 0 0 #F7F7F7;
color: #383838;
font-size: 12px;
font-weight: bold;
line-height: 16px;
margin: 17px 0 10px;
padding: 6px 0 6px 8px;
}
#content #right ul li .info .price {
color: #383838;
font-size: 12px;
font-weight: bold;
line-height: 16px;
padding-top: 25px;
}
#content #left ul li .info .price .st {
color: #7F7F7F;
font-size: 11px;
line-height: 16px;
margin-right: 3px;
}
#content #right ul li .info .price .usual, #content #right ul li .info .price .special {
color: #7F7F7F;
font-size: 12px;
font-weight: normal;
line-height: 16px;
padding-right: 6px;
text-decoration: line-through;
}
#content #right ul li .info .price .special {
color: #FD7A01;
font-weight: bold;
text-decoration: none;
}
#content #left ul li .info .actions {
overflow:hidden;
}
#content #left ul li .info .actions a {
border: 1px solid #E0E0E0;
color: #fd7a01;
display: block;
float:right;
font-size: 11px;
font-weight: bold;
line-height: 16px;
padding: 5px;
text-decoration: none;
}
#content #left ul li .info .actions a:first-child {
color: #009832;
float:left;
}
If you can provide me a solution it'd be much appreciated.
You missed the position attributes for your position: absolute.
By adding:
right: 0;
top: 10px;
solves the issue (of course, you can custom that for your needs)
Working example: https://codepen.io/cdtapay/pen/OdRowv
I have been working on fixing this but cannot figure out what I am missing. I would like for drop down list to show right below its parent. The list shows but all go to far left and forces the remaining nav items to drop down to another line. i have included a snippet for what is currently looks like and an image of what I want it to look like. Also, I have been trying to figure out how to add down fa fa-caret to nav items with drop down list. Please help!
.navbar {
background: linear-gradient(#9E0A0C, #EBEBEB);
padding: 10px;
border-top: solid 1px #000000;
overflow: hidden;
}
.navbar a {
text-decoration: none;
color: #ffffff;
font-weight: bolder;
font-size: 20px;
text-transform: uppercase;
padding: 3px 5px;
margin: auto;
/*float: left; may need to be removed to show borders*/
display: inline;
}
.navbar ul {
padding: 0;
margin-top: 0;
width: auto;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
}
.navbar a:active {
background-color: #000000;
}
.navbar a:hover {
background-color: #ddd;
color: black;
font-size: 20px;
}
li:first-child {
border-left: none;
}
.dropdown {
display: block;
overflow: hidden;
/*float: left;*/
}
.list {
display: none;
min-width: 50px;
max-width: 150px;
z-index: 2;
box-shadow: 0 8px 16px 0 #e7e7e7;
background: #050243;
}
.list a {
color: #000000;
float: none;
font-size: 14px;
text-decoration: none;
display: block;
text-align: left;
background: #B6B6B6;
columns: 2;
}
.list a:hover {
background-color: #EEEEEE;
}
.dropdown:hover .list {
display: block;
}
form {
float: right;
padding: 0px;
margin: 0;
overflow: auto;
}
input {
border: solid 1px #000000;
background-image: url(pics/search.png);
background-repeat: no-repeat;
background-position: center right;
background-size: 15px;
border-radius: 5px;
padding: 5px 2px;
width: 250px;
}
<div class="navbar">
<ul>
<li>Home</li>
<li class="dropdown">Our Lodge
<div class="list">
NEWS
FACILITIES
OFFICERS
GUEST BOOK
</div>
</li>
<li class="dropdown">Events
<div class="list">
CALENDAR
BINGO
</div>
</li>
<li class="dropdown">Contact Us
<div class="list">
BECOME AN ELK
</div>
</li>
<form action="#">
<input type="text" placeholder="Search.." name="search">
</form>
</ul>
</div>
You can achieve this by first making the div.list element into an absolute positioned. The 'display:block' property was pushing all the other content down to the next row because the block element was taking up space.
As you see now the list is no longer pushing the content down but now it is not aligned to the correct nav item. We are also going to add a left:0 so that the div.list is to the left of the parent property.
Now the parent property needs a position of relative so that the left:0 on the child element is being positioned relative to the parent element.
.dropdown:hover .list {
display: block;
position: absolute;
left: 0;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
position: relative;
}
The problem with your CSS code is, you missed to add position: relative and position: absolute to the .dropdown and .list selectors, which is compulsory to create dropdown. Try this code.
.navbar {
background: linear-gradient(#9E0A0C, #EBEBEB);
padding: 10px;
border-top: solid 1px #000000;
}
.navbar a {
text-decoration: none;
color: #ffffff;
font-weight: bolder;
font-size: 20px;
text-transform: uppercase;
padding: 3px 5px;
margin: auto;
/*float: left; may need to be removed to show borders*/
display: inline;
}
.navbar ul {
padding: 0;
margin-top: 0;
width: auto;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
}
.navbar a:active {
background-color: #000000;
}
.navbar li:hover > a {
background-color: #ddd;
color: black;
}
li:first-child {
border-left: none;
}
.dropdown {
display: block;
overflow: hidden;
position: relative;
/*float: left;*/
}
.list {
display: none;
min-width: 50px;
max-width: 150px;
z-index: 2;
box-shadow: 0 8px 16px 0 #e7e7e7;
background: #050243;
position: absolute;
left: 0;
top: 100%;
}
.list a {
color: #000000;
float: none;
font-size: 14px;
text-decoration: none;
display: block;
text-align: left;
background-color: #B6B6B6;
columns: 2;
}
.list a:hover {
background-color: #EEEEEE;
}
.dropdown:hover .list {
display: block;
}
form {
float: right;
padding: 0px;
margin: 0;
overflow: auto;
}
input {
border: solid 1px #000000;
background-image: url(pics/search.png);
background-repeat: no-repeat;
background-position: center right;
background-size: 15px;
border-radius: 5px;
padding: 5px 2px;
width: 250px;
}
--> Please update following code in your existing file
.navbar {
background: linear-gradient(#9E0A0C, #EBEBEB);
padding: 10px;
border-top: solid 1px #000000;
}
.navbar a {
text-decoration: none;
color: #ffffff;
font-weight: bolder;
font-size: 20px;
text-transform: uppercase;
padding: 3px 5px;
margin: auto;
display: inline;
}
.navbar ul {
padding: 0;
margin-top: 0;
width: auto;
}
.navbar li {
border-left: solid 2px #000000;
display: inline;
list-style-type: none;
width: 800px;
padding: 0;
position: relative;
}
.navbar a:active {
background-color: #000000;
}
.navbar a:hover {
background-color: #ddd;
color: black;
}
li:first-child {
border-left: none;
}
.dropdown {
display: block;
overflow: hidden;
}
.list {
opacity: 0;
visibility: hidden;
min-width: 50px;
max-width: 150px;
z-index: 2;
box-shadow: 0 8px 16px 0 #e7e7e7;
background: #050243;
position: absolute;
top: 20px;
left: 0;
transition: 0.3s ease-in-out;
}
.list a {
color: #000000;
float: none;
font-size: 14px;
text-decoration: none;
display: block;
text-align: left;
background: #dddddd;
columns: 2;
}
.list a:hover {
background-color: #EEEEEE;
}
.dropdown:hover .list {
opacity: 1;
visibility: visible;
}
form {
float: right;
padding: 0px;
margin: 0;
overflow: auto;
}
input {
border: solid 1px #000000;
background-image: url(pics/search.png);
background-repeat: no-repeat;
background-position: center right;
background-size: 15px;
border-radius: 5px;
padding: 5px 2px;
width: 250px;
}
<div class="navbar">
<ul>
<li>Home</li>
<li class="dropdown">Our Lodge
<div class="list">
NEWS
FACILITIES
OFFICERS
GUEST BOOK
</div>
</li>
<li class="dropdown">Events
<div class="list">
CALENDAR
BINGO
</div>
</li>
<li class="dropdown">Contact Us
<div class="list">
BECOME AN ELK
</div>
</li>
<form action="#">
<input type="text" placeholder="Search.." name="search">
</form>
</ul>
</div>
I have a rather nice navbar but unfortunatly, when I resize my laptop window a bit, the text starts overlapping. It seems to be stuck in the middle and wont make use of all the space, despite me having checked throughly that here are no padding or margins causing this.
This is how it looks on a big screen
this is the problem when I narrow the window a bit
Could someone please help me figure out why this is happening, please?
I would be very grateful.
My main CSS navbar (displayed on small screens):
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
/* I tilfælde af at der skal cleares */
br.tabula {
clear: both;
}
a {
text-decoration: none;
color: orange;
}
/*Fjerner underline osv.*/
a:link, a:visited {}
a:hover {}
a:active {}
/***********************************************************/
/* Specielle! */
/***********************************************************/
/***********************************************************/
/* Billeder! Img! ****** Video! */
/***********************************************************/
#burger {
width: 15px
}
img.lille-l {
float: left;
margin: 8px 20px 20px 0;
width: 160px;
height: 165px;
}
img.mellem-r {
float: right;
padding: 20px;
width: 350px;
}
img.top {
margin: 8px 0 20px 0;
}
.sponsor {
width: 50px;
height: 50px;
border: 0;
padding-bottom: 22px;
}
.klik {
padding: 5px;
box-shadow: 3px 5px #888888;
}
#socialbar img {
width: 30px;
height: 30px;
}
iframe {
width: 390px;
height: 250px;
float: left;
padding: 10px 15px 10px 0px;
border: none;
}
/***********************************************************/
/* Tekst! */
/***********************************************************/
h1, h2, h3 {
margin: 0 0 1% 0
}
/*****************************************************************************/
/* HEADER! ****** BANNER! */
/******************************************************************************/
#bannerkat {
margin-top: 1%;
width: 100%;
height: 46px;
background-image: url("billeder/katte/mathilde.jpg");
background-size: cover;
color: white;
border-bottom: solid 1px #444444;
}
/******************************************************************************/
/* NAV! */
/******************************************************************************/
/* Menu Button */
#menu-button {
z-index: 1;
text-align: center;
padding: 5px 5px 5px 5px;
position: absolute;
position: fixed;
top: 15px;
right: 5px;
transition: all 0.2s ease;
cursor: pointer;
width: 50px;
height: 35px;
background-color: #19c589;;
border-radius: 5px; /* pæne runde hjørner*/
-moz-border-radius: 5px; /* Fox*/
-webkit-border-radius: 5px; /* IE */
}
nav p {display:none;}
#mainlogo {display:none;}
#menu-button .bar {
display: block;
height: 4px;
background: black;
margin: 4px;
}
#menu-checkbox {
display: none;
}
#menu-checkbox:checked ~ #menu-button {
transform: rotate(90deg);
}
nav ul {
position: fixed;
display: none;
width: 100%;
}
#menu-checkbox:checked ~ #menu {
display: block;
}
#menu {
display: none;
list-style: none;
margin: 0;
padding: 0;
border-radius: 20px;
overflow: hidden;
}
#menu li {
width: 100%;
background-color: beige;
text-align: center;
padding: 7px 2px 7px 2px;
}
This is the code for the nav in the images, displayed on larger screens with media query:
#mainlogo {display: block;}
#bannerkat {display: none;}
#menu-button {
display: none;
}
#menu {
display: block;
border-radius: 0;
text-align: center;
position: relative;
}
.mainheader {width: 100%; padding: 0 auto;
margin: 0}
#menu ul {width:100%; padding: 0 auto;
margin: 0}
#menu li {
display: inline-block;
width: 12%;
background: none;
padding: 0 ;
margin: 0;
}
#menu li a {
font-size: normal;
text-decoration: none;
color: #505050;
text-align: center;
line-height: 75px;
text-transform: uppercase;
transition: all .4s ease;
display: inline-block;
width: 100%;
border-top: 5px solid #80bb80;
}
#menu li:nth-of-type(2) a {
border-top: 5px solid #9b5e5e;
}
#menu li:nth-of-type(3) a {
border-top: 5px solid #5656b3;
}
#menu li:nth-of-type(4) a {
border-top: 5px solid grey;
}
#menu li a:hover {
border-top: 5px solid darkgreen;
}
}
nav { font-family: helvetica, arial, sans-serif;}
/* højde for billed-sektion*/
section {min-height: 204px;}
#baggrund {
background:
url("billeder/katte/sophi.png");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;}
#mainlogo {
font-size: 37px;
color: white;
border: 7px solid white;
display: inline-block;
padding: 10px;
position: absolute;
height: 123px;/* hvid boks*/
line-height: 25px;
top: 202px;
margin-top: -180px;
left: 50%;
width: 600px;
text-align: center;
margin-left: -300px;
text-shadow: 1px 2px 1px #000;
box-shadow: 1px 2px 1px #000; }
/* og omegns */
#mainlogo p {font-size: 20px; padding:5px;}
.vector{width: 60px;
margin-left: -450px;
margin-top: -36px;}
.mainheader {margin-top: 10px;}
/* Navigations menuen (links osv) */
#nav_wrap {
background: #f9f4ea;
width: 100%;
white-space: nowrap;
float: left;
height: auto;;
position: relative;
margin-top: 144px;
bottom: 0;
overflow: hidden;
z-index: 00;
opacity: .9;
box-shadow: 0px 1px 4px beige;
padding: 0;
}
/* MAIN! BODY! *********************************************************/
body {
background-image: url("billeder/bgorange.jpg");
background-size: cover;
color: black;
/* Base font size (14px)? 7%*/
font-family: sans-serif, arial;
line-height: 1.5;
text-align: left;
}
.body { width: 90%;}
.maincontent {
line-height: 20px;
width: 79%;
float: left;
border-radius: 5px;
/* pæne runde hjørner*/
-moz-border-radius: 5px;
/* Fox*/
-webkit-border-radius: 5px;
/* IE */
}
#Ginger
You should remove fixed width: 12% from #menu li.
#menu li word needs to be wrapped and font-size should be small on lower screen size. i.e word-wrap:break-word
i'm redesigning my website. and doing that i'm finding myself in some problems using the css code i wrote.
i use div's to get an image and some text next to each other.
i'm unable to get the text moved to the correct place (see pictures) the margin-left doesn't seem to work when it is in the css file but it works when directly embedded in the div tags, am i doing something wrong?
also i'dd like to add that i don't need to set the image size in the html code but its in the css code is this possible?
What i get
What i want
body
{
background:#333 url(bg.jpg) repeat top left;
font-family:Arial;
color:white;
text-align:center;
}
body header.heading
{
width:1150px;
/*background:transparent url(../images/menu/MEbanner.jpg) no-repeat top;
background-size: 1150 100px;
padding-top:101px;*/
margin:0 auto;
z-index:0;
}
body.Content
{
width:1150px;
}
main
{
width:1150px;
margin: 0 auto;
}
section
{
text-align:left;
margin:0 auto;
}
header nav
{
width:1150px;
background:transparent url(../images/menu/MEbanner.jpg) no-repeat top;
background-size: 1150 100px;
padding-top:101px;
margin:0 auto;
z-index:0;
}
header nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
header nav li {
float: left;
border-right: 1px solid #bbb;
}
header nav li:last-child {
border-right: none;
}
/*header nav li a {
display: block;
color: white;
text-align: center;
padding: 20px 16px;
text-decoration: none;
}*/
/* Change the link color to #111 (black) on hover */
header nav li a:hover {
background-color: #111;
}
header nav li.active {
background-color: #4CAF50;
}
header nav li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 20px 16px;
text-decoration: none;
}
header nav li a:hover, .dropdown:hover .dropbtn {
background-color: #111;
}
header nav li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
nav
{
text-align:left;
margin:0 auto;
}
.hidden {display:none}
hr
{
border-left: none;
border-right: none;
height:4px;
margin: 2em 0 2em 0;
}
main a:link {color:#fff;} /* unvisited link */
main a:visited {color:#fff;} /* visited link */
main a:hover {color:#159;} /* mouse over link */
blockquote{
color:white;
border-left: 8px solid;
border-color: #0BD676;/*#0DFF8C;*/
padding-left:10px;
}
h2
{
font-size: 30px;
color:Black;
}
h1,h2,h3,h4
{
font-family: 'Open Sans Condensed', sans-serif;
color:#4CAF50;
text-decoration:underline;
}
h2, h3
{
font-size: 1.6em;
letter-spacing: -1px;
margin: 0 0 0.75em 0;
}
h3
{
font-size:1.3em;
}
h1
{
font:bold;
}
h4
{
font-size:1em;
margin: 0.5em 0 0.5em;
padding-left:1em;
}
.green
{
border-left: 8px solid;
border-color: #0BD676;/*#0DFF8C;*/
padding-left:10px;
color: #4CAF50;
margin-left:40px;
font-style:oblique;
}
article.centeralign
{
text-align:center;
}
div.wrapper{
width: 800px;
overflow: hidden;
}
div.toolsWrapper{
width: 980px;
overflow: hidden;
}
div.left{
width: 200px;
float:left;
margin-right:40px;
padding-left:40px;
}
div.right{
float:left;
margin-left: 20px;
}
div.cc
{
width:200px;
text-align:right;
font-size:10px;
}
div.ccf
{
text-align:center;
font-size:12px;
}
iframe
{
text-align:center;
float:center;
}
/* ===========================
====== Contact Form =======
=========================== */
input, textarea {
padding: 10px;
border: 1px solid #E5E5E5;
width: 200px;
color: #999999;
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
}
textarea {
width: 400px;
height: 150px;
max-width: 400px;
line-height: 18px;
}
input:hover, textarea:hover,
input:focus, textarea:focus {
border-color: 1px solid #C9C9C9;
box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 8px;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 0px 8px;
}
.form label {
margin-left: 10px;
color: #999999;
}
/* ===========================
====== Submit Button ======
=========================== */
.submit input {
width: 100px;
height: 40px;
background-color: #474E69;
color: #FFF;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
table, th, td {
border: 1px solid black;
border-color:white;
}
th, td {
padding: 15px;
}
.blue{
background: url(blue.png) no-repeat left center;
color: #109CEF;
padding: 0px 40px 0px 20px;
font-style:oblique;
}
.red{
background: url(red.png) no-repeat left center;
color:#FF0000;
padding: 0px 40px 0px 20px;
font-style:oblique;
}
<article>
<h1>Audio Projects</h1>
<blockquote>
<h3>
<a href="Damp">
Class D Amplifier
</a>
</h3>
<div class="wrapper">
<div class="left">
<img src="Damp/Damp_front.JPG"/>
</div>
<div class="right">
Some text that should be next to image
</div>
</div>
</blockquote>
</article>
I changed those:
.h1 {
text-align: left;
}
.h3 {
text-align: left;
}
div.left{
float: left;
}
div.right {
width: 500px;
float: left;
margin-left: 20px;}
results
https://i.stack.imgur.com/7rswY.png
You just need to change a few styles, and replace the <article> with a <div> (For IE support)
div.wrapper {
width: 800px;
overflow: hidden;
}
div.toolsWrapper {
width: 980px;
overflow: hidden;
}
div.left {
width: 200px;
float: left;
margin-right: 40px;
padding-left: 40px;
}
div.right {
color: white;
display: inline-block;
position: absolute;
top: 0;
}
.wrapper {
position: relative;
width: 50%;
}
.title {
color: #4B9F49;
}
.inner_title {
color: white;
}
.blockquote {
border-left: 3px solid #0CD673;
padding-left: 5px;
}
#article {
background: black;
}
<div id="article">
<h3>
Audio Projects
</h3>
<blockquote class="blockquote">
<h3>
Class D Amplifier
</h3>
<div class="wrapper">
<img src="Damp/Damp_front.JPG" style="height:80px; width:200px;"/>
<div class="right">
Some text that is now next to the image.
</div>
</div>
</blockquote>
</div>
I guess problem is with width of left class division. Try to make it auto.
div.left{
width: auto;
....
}
Option 1, my preferred way of doing this:
Remove the float in .left take the inline left margin out of the .right and give both .left and .right
display: inline-block;
Giving you
div.left{
width: 200px;
/*float:left;*/
display: inline-block;
margin-right:40px;
padding-left:40px;
}
div.right{
display: inline-block;
width: 520px;
margin-left: 20px;
}
For those two classes
Option 2:
Give both a float:left
div.left{
width: 200px;
float:left;
margin-right:40px;
padding-left:40px;
}
div.right{
float:left;
width: 520px;
margin-left: 20px;
}
This should cause them to stack in the same way that inline-block does, but floats can cause trouble later. In either case you have to limit the width on .right or the text will prefer to be full width and not be inline, but rather be below the image. The total width of the two divs has to be less than the available width in .wrapper
Your image is probably larger than the .left container (given that this is the only element that is not included in your snippet to test properly).
Try the following ...
img{
height: auto;
width: auto;
max-height: 100%;
max-width: 100%;
}
... you should probably add a class for that image, rather than styling all images this way.
well, what i can advice you is to put the text in the same division as the image like in paragraph tag and then give the image css attribute called "float:left" according to what you want.
thank you
hope this is going to help you
use .classname only
instead of div.classname