I have created Html menu as follow
Football
Basketball
Baseball
then my css file is as follow:
#main-nav a
{
display: block;
float: left;
margin: 125px 0px 0px 0px;
color: #666666;
border: 1px #C0C0C0 solid;
background-color: #EEEEEE;
font-family: Arial;
font-size: 13px;
font-weight: normal;
font-style: normal;
text-decoration: none;
width: 106px;
height: 78px;
vertical-align: middle;
line-height: 78px;
text-align: center;
}
#main-nav a:hover, #main-nav .active
{
color: #666666;
background-color: #C0C0C0;
border: 1px #C0C0C0 solid;
}
I am trying to customize it a bit more by adding 30*30 icon of football etc in each corresponding button
i have tried to make every image as a Div and use position to make it in the corresponding button but this solution is fragile and not the best option.
can idea of better solution?
You can try this code:
<div id='main-nav'> Football<div class='icon'></div>
Basketball<div class='icon'></div>
Baseball<div class='icon'></div>
</div>
whit this css:
#main-nav a {
display: block;
float: left;
margin: 125px 0px 0px 0px;
color: #666666;
border: 1px #C0C0C0 solid;
background-color: #EEEEEE;
font-family: Arial;
font-size: 13px;
font-weight: normal;
font-style: normal;
text-decoration: none;
width: 106px;
height: 78px;
vertical-align: middle;
line-height: 78px;
text-align: center;
position : relative;
}
#main-nav a .icon {
height: 30px;
width : 30px;
background : red;//change this for the img.
position : absolute;
top : 0;
left : 35px;
}
#main-nav a:hover, #main-nav .active {
color: #666666;
background-color: #C0C0C0;
border: 1px #C0C0C0 solid;
}
Changing the red background for a background: url(/path/to/image)
Please, take a look at this jsfiddle.
Note: include a <div> intro a <a> it's valid in html5 but not in html 4.01. More info here.
Try this
#main-nav a
{
display: block;
float: left;
margin: 125px 0px 0px 0px;
color: #666666;
border: 1px #C0C0C0 solid;
font-family: Arial;
font-size: 13px;
font-weight: normal;
font-style: normal;
text-decoration: none;
width: 115px;
height: 78px;
vertical-align: middle;
line-height: 78px;
text-align: center;
background:url(http://img6a.flixcart.com/image/ball/4/g/g/vector-x-football-england-100x100-imade784dbrjbdzp.jpeg) no-repeat 50% 99% #EEEEEE;
background-size:25px
}
#main-nav a:nth-child(2){
background:url(http://www.iconshock.com/img_jpg/BRILLIANT/sports/jpg/128/american_football_icon.jpg) no-repeat 50% 99% #EEEEEE;
background-size:25px
}
#main-nav a:nth-child(3){
background:url(http://www.iconshock.com/img_jpg/BRILLIANT/sports/jpg/128/archery_icon.jpg) no-repeat 50% 99% #EEEEEE;
background-size:25px
}
DEMO
DEMO UPDATED
try this. your html
<div id="main-nav">
Football
Cricket
Tennis
</div>
css
#main-nav a
{
display: block;
float: left;
margin: 125px 0px 0px 0px;
color: #666666;
border: 1px #C0C0C0 solid;
background-color: #EEEEEE;
font-family: Arial;
font-size: 13px;
font-weight: normal;
font-style: normal;
text-decoration: none;
width: 106px;
height: 78px;
vertical-align: middle;
line-height: 78px;
padding-left:50px;
}
#main-nav a.football{
background:url("http://icons.iconarchive.com/icons/ampeross/qetto/32/icon-developer-icon.png") no-repeat 10px;
}
#main-nav a.cricket{
background:url("http://icons.iconarchive.com/icons/deleket/3d-cartoon/32/Axialis-Icon-Workshop-icon.png") no-repeat 10px;
}
#main-nav a.tennis{
background:url("http://icons.iconarchive.com/icons/deleket/mac-folders/32/Blue-Apple-icon.png") no-repeat 10px;
}
#main-nav a:hover, #main-nav .active
{
color: #666666;
background-color: #C0C0C0;
border: 1px #C0C0C0 solid;
}
my fiddle http://jsfiddle.net/ponrajpaul/4VMa4/
or if you want to use same icon for all links, remove all class names from a tags and use like this
<div id="main-nav">
Football
Cricket
Tennis
<div>
#main-nav a{
background:url("http://icons.iconarchive.com/icons/deleket/3d-cartoon/32/Axialis-Icon-Workshop-icon.png") no-repeat 10px;
}
a:nth-child(numbers) will not support in ie6. If you dont need ie old
browsers support, nth-child method is best to you..
Related
I basically have a navigation bar on the top with 6 hyperlinks and I have coded for each of them. However the hyperlink doesnt work properly. Upon further research I found that the hyperlink will be active only when clicked in a certain location. Usually top-middle of text. Here is the code I'm using. Thanks in advance for your help.
#nav {
width: 100%;
height: 550px;
background-color: #FFFFFF;
background-size: cover;
background-image: url();
border-bottom: thin solid;
font-size: large;
color: #FFFFFF;
margin-top: 0px;
;
border-bottom: thin solid #FFFFFF;
font-size: large;
color: #FFFFFF;
margin-top: 0px;
text-shadow: 0px 0px #FFFFFF;
}
#nav_wrapper {
height: 66px;
width: 100%;
margin-left: auto;
opacity: 0.8;
filter: alpha (opacity=70);
border-bottom: thin inset #000000;
text-align: right;
font-family: "SamsungSharpSansRegular Regular";
}
#nav_wrapper ul li {
list-style: none;
display: inline;
font-weight: bold;
padding: 10px;
color: #000000;
}
#nav_wrapper a {
color: #000000;
text-decoration: none;
padding: 10px;
}
#nav_wrapper ul li:hover {
background: #FFFFFF;
transition: all 0.45s;
}
<div id="nav"><br>
<div id="nav_wrapper"><br>
<ul>
<li>Home</li>
<li>About Us</li>
<li>Developers</li>
<li>S9 | S9+</li>
<li>Forum</li>
<li>Recent</li>
</ul>
</div>
I know this sounds like an obvious question and answer, but I have spent a long time trying to figure this out, and for some reason, none of the answers are not working for me. Honestly, this is probably going to be a simple obvious answer I just can't catch. But here's the problem: I am making a website out of HTML5, CSS, and some PHP.
The issue is, that my links appear blue and purple with an underline. I know this is how they are supposed to look, but I have tried many different ways to re-style the links with text-decoration: none, and different colors and so on.
Here is my CSS and the HTML part with a link:
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
a {
text-decoration: none;
color: brown;
}
.sidebar {
width: 25%;
height: 100%;
float: left;
background-color: #BC986A;
overflow-y: scroll;
}
.side-option {
width: 100%;
height: 155px;
background-color: #BC986A;
}
.side-option:hover, .side-option:focus {
background-color: #DAAD86;
}
.side-name {
font-family: "Indie Flower", cursive;
font-size: 1.8em;
margin: 2px 2px 0px 7px;
padding: 5px 5px 0px 5px;
}
.side-image {
width: 150px;
height: 97px;
margin: 0px 0px 0px 15px;
border: 0.3em solid #FBEEC1;
}
.info {
background-color: #659DBD;
width: 75%;
height: 100%;
float: right;
}
#name {
font-family: "Gloria Hallelujah", cursive;
font-size: 50px;
text-align: center;
color: #FBEEC1;
}
#s-name {
font-family: "Gloria Hallelujah", cursive;
font-size: 20px;
text-align: center;
color: #FBEEC1;
}
#image {
display: block;
width: 384px;
height: 256px;
margin-left: auto;
margin-right: auto;
border: 0.5em solid #BC986A;
margin-top: 10px;
}
#desc {
font-family: "Rock Salt", cursive;
font-weight: bold;
font-size: 20px;
text-align: center;
color: #DAAD86;
}
<div class="sidebar">
<a href="index.php?page=0"><div class="side-option">
<h2 class="side-name">Brown Bear</h2>
<img src="http://maxpixel.freegreatpicture.com/static/photo/1x/Animal-Brown-Bear-Beast-Bear-Teddy-Bear-Mammal-422682.jpg" class="side-image" alt="Brown bear standing in tall plants.">
</div></a>
I'm not sure if you needed all that, but there it is anyway.
For hover color change you can use this css
.sidebar a:hover{color:red; }
For keep the color focus after click
.sidebar a:focus{color:blue; }
1) You need to change your code from </div></a> at the end to this: </div></a></div>
2)Links can be styled differently depending on what state they are in.:
a:link - a normal, unvisited link
a:visited - a link the user has visited
a:hover - a link when the user mouses over it
a:active - a link the moment it is clicked
You can read more about this in: https://www.w3schools.com/css/css_link.asp
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
a, a:link, a:visited{
text-decoration: none;
color: brown;
}
a:hover, a:active{
color: green;
}
.sidebar {
width: 25%;
height: 100%;
float: left;
background-color: #BC986A;
overflow-y: scroll;
}
.side-option {
width: 100%;
height: 155px;
background-color: #BC986A;
}
.side-option:hover, .side-option:focus {
background-color: #DAAD86;
}
.side-name {
font-family: "Indie Flower", cursive;
font-size: 1.8em;
margin: 2px 2px 0px 7px;
padding: 5px 5px 0px 5px;
}
.side-image {
width: 150px;
height: 97px;
margin: 0px 0px 0px 15px;
border: 0.3em solid #FBEEC1;
}
.info {
background-color: #659DBD;
width: 75%;
height: 100%;
float: right;
}
#name {
font-family: "Gloria Hallelujah", cursive;
font-size: 50px;
text-align: center;
color: #FBEEC1;
}
#s-name {
font-family: "Gloria Hallelujah", cursive;
font-size: 20px;
text-align: center;
color: #FBEEC1;
}
#image {
display: block;
width: 384px;
height: 256px;
margin-left: auto;
margin-right: auto;
border: 0.5em solid #BC986A;
margin-top: 10px;
}
#desc {
font-family: "Rock Salt", cursive;
font-weight: bold;
font-size: 20px;
text-align: center;
color: #DAAD86;
}
<div class="sidebar">
<a href="index.php?page=0"><div class="side-option">
<h2 class="side-name">Brown Bear</h2>
<img src="http://maxpixel.freegreatpicture.com/static/photo/1x/Animal-Brown-Bear-Beast-Bear-Teddy-Bear-Mammal-422682.jpg" class="side-image" alt="Brown bear standing in tall plants."/>
</div>
</a>
</div>
a {
text-decoration: none;
color: brown;
}
is where you need to make changes to edit links
to change hover options:
a:hover {
style it here
}
and for already visited links on your site:
a:visited {
style it here
}
You asked how to style links.
a{
color: red;
cursor: wait;
font-size: 24px;
transition: color 0.3s, text-shadow 0.3s;
text-decoration: none;
}
a:hover{
color: green;
text-shadow: 1px 2px 3px #000;
text-decoration: overline;
}
a:active{
font-weight: 900;
}
Working link.
I want to change background color (from #333333 to #292929) and keep parent image after making hover event on my list items, my problem is the color doesn't change it still always as before
this is my code :
the part of my problem:
.footer li a:hover {
border-bottom: 1px solid #484848;
border-top: 1px solid #191919;
height: 30px;
line-height: 30px;
border-left: none;
border-right: none;
display: block;
background: #292929 url(http://s10.postimg.org/yejg5cted/widget_bg.jpg);
overflow:hidden;
width: 100%
}
All css code
.footer {
background: #333333 url(http://s10.postimg.org/yejg5cted/widget_bg.jpg);
height: 318px;
}
.footer_container {
width: 960px;
height: 318px;
margin: 0 auto;
}
.footer h1 {
font-size: 18px;
font-family: Kozuka Gothic Pro;
padding-top: 46px;
color: #FFF;
}
ul.ul_links {
width: 225px;
height: 237px;
margin-top: 19px;
}
ul.ul_links a {
color: #cccccc;
text-decoration: none;
font-size: 13px;
line-height: 31px;
}
ul.ul_links a::before {
content: url(http://s3.postimg.org/7bb9a1m4v/links.png);
padding-right: 11px;
padding-left: 8px;
}
.footer li a:hover {
border-bottom: 1px solid #484848;
border-top: 1px solid #191919;
height: 30px;
line-height: 30px;
border-left: none;
border-right: none;
display: block;
background: #292929 url(http://s10.postimg.org/yejg5cted/widget_bg.jpg);
overflow:hidden;
width: 100%
}
jsfiddle
intending results :
Hello there TH3 AWAK3NING, what you need to do is simply change the opacity of your background like so
jsFiddle : https://jsfiddle.net/py3uwpxn/11/
HTML
<div class="footer">
<div class="footer_container">
<div class="Links">
<ul class="ul_links">
<li >www.example.com</li>
<li >www.1stwebdesigner.com</li>
<li >www.labzip.com</li>
<li >www.labzip.com</li>
<li >www.samplelink.com</li>
<li >www.outgoinglink.com</li>
<li >www.link.com</li>
</ul>
</div>
</div>
</div>
CSS
.footer {
background: #333333 url(http://s10.postimg.org/yejg5cted/widget_bg.jpg);
height: 318px;
}
.footer_container {
width: 960px;
height: 318px;
margin: 0 auto;
}
.footer h1 {
font-size: 18px;
font-family: Kozuka Gothic Pro;
padding-top: 46px;
color: #FFF;
}
ul.ul_links {
width: 225px;
height: 237px;
margin-top: 19px;
}
ul.ul_links a {
color: #cccccc;
text-decoration: none;
font-size: 13px;
line-height: 31px;
}
ul.ul_links a::before {
content: url(http://s3.postimg.org/7bb9a1m4v/links.png);
padding-right: 11px;
padding-left: 8px;
}
.footer li a:hover {
border-bottom: 1px solid #484848;
border-top: 1px solid #191919;
height: 30px;
line-height: 30px;
border-left: none;
border-right: none;
display: block;
background: rgba(0,0,0,.1);
overflow:hidden;
width: 100%
}
Using the background: rgba it also allows you to tint the colour of the div which will look like you have changed the colour of the background :)
This will not be possible because the actual image is what defines the original color. What you would need to do in this case is create the image with a transparent background (so it only has the grid dots) then you would be able to change the background color behind it and see the effect you want.
Once you have your new image, set the following properties:
ul.ul_links a {
background: #333333 url(http://s10.postimg.org/yejg5cted/widget_bg.jpg);
}
.footer li a:hover {
background-color: #292929;
}
Here is an example that just needs the new transparent image to be added
Just remove the background image Url from .footer li a:hover and you are good.
.footer li a:hover {
border-bottom: 1px solid #484848;
border-top: 1px solid #191919;
height: 30px;
line-height: 30px;
border-left: none;
border-right: none;
display: block;
background-color: rgba(0,0,0,0.2); //Updated
overflow:hidden;
width: 100%
}
I have made some buttons to link people from my site to social media pages and the text in the Google Plus one is too low and I would like it to go higher in the div but I am struggling to do this, my code is here on JS fiddle.
The buttons aren't complete yet, I just want to know how to get the text higher, cheers
.GooglePlus {
color: black;
font-size: 35px;
border-radius: 100px;
padding: 2px;
font-family: Garamond;
font-weight: bold;
height: 40px;
width: 40px;
background-color: #D8D8D8;
text-align: center;
vertical-align: central;
}
a:hover .GooglePlus {
background-color: #FE2E2E;
color: white;
}
Just add line-height:27px; to adjust g+
Code full class:
.GooglePlus {
color: black;
font-size: 35px;
border-radius: 100px;
padding: 2px;
font-family: Garamond;
font-weight: bold;
height: 40px;
width: 40px;
background-color: #D8D8D8;
text-align: center;
vertical-align: middle;
line-height:27px;
}
If i understand you correctly you are just trying to move the text inside of those circle backgrounds higher.
If this is the case you can cheat it with line height as done in this fiddle
http://jsfiddle.net/9dj9u/2/
Which leaves the resulting CSS affected.
.FaceBook {
color: black;
font-size: 35px;
border-radius: 100px;
padding: 2px;
font-family: Calibri;
font-weight: bold;
height: 40px;
width: 40px;
background-color: #D8D8D8;
text-align: center;
line-height:1.1;
}
.GooglePlus {
color: black;
font-size: 35px;
border-radius: 100px;
padding: 2px;
font-family: Garamond;
font-weight: bold;
height: 40px;
width: 40px;
background-color: #D8D8D8;
text-align: center;
vertical-align: middle;
line-height:0.8;
}
Just adjust line-height in percentage values: line-height: 50%, keep increasing or decreasing till you get there, you might also want to adjust padding, and box-sizing... and remove vertical-align
Remember, this isn't quite exact science, because you do not intend the g and the f to stand next to each other like they do in a sentence, watch this: fg, notice how the g normally is indeed lower than the f.
i included the correct vertical-align value and adjusted the height and width
.FaceBook {
color: black;
font-size: 35px;
border-radius: 100px;
padding: 5px;
font-family: Calibri;
font-weight: bold;
height: 40px;
width: 40px;
background-color: #D8D8D8;
text-align: center;
}
a:hover .FaceBook {
background-color: #4c66a4;
color: white;
}
#footer .FaceBook {
display: inline-block;
}
.GooglePlus {
color: black;
font-size: 35px;
border-radius: 100px;*/
border-bottom: 2px solid black;
padding: 2px;
font-family: garamond;
font-weight: bold;
height: 50px;
width: 50px;
background-color: #D8D8D8;
text-align:center ;
vertical-align: text-bottom;
padding: 0px;
}
a:hover .GooglePlus {
background-color: #FE2E2E;
color: white;
}
#footer .GooglePlus {
display: inline-block;
}
#plus {
font-size: 20px;
padding:0px 0px;
}
a {
text-decoration: none;
}
My website is on the local server right now however this will be a simple fix for those of you who know whats it's called.
I'm trying to get these lists (bordered in white) to float the the far left in the available space of the footer(bordered by black).
This is my CSS
#footer { width: 100%; height: 503px; background: url(img/FOOTER-bg.jpg) repeat-x; background-color: #821d20; position: relative; top: 100px;/*border: 1px solid #0C0;*/}
#footer a { text-decoration: underline; color: #c7bd89; }
#footer a:hover { text-decoration: none; color: #fff; }
#footer h6 { background: url(img/FOOTER-HR-BG.jpg) left center repeat-x; text-align: left;}
#footer h6 span { background: #8e2023; display: inline-block; padding-right: 5px; }
.footer-widgets { width: 960px; height: 503px; margin: 0px auto; padding: 0px; border: 1px solid #000;}
.footer-widgets li { width:280px; height: auto; list-style-image: none; list-style-position: outside; list-style-type: none; float: left; color: #fff; padding: 13px; margin-right: 10px; /*border: 1px solid #fff;*/ }
.footer-widgets li ul {color: red;}
.footer-widgets li ul li {color: #fff; margin-left: -50px; margin-top: -15px;}
.footer-widgets li p { font-size: 1em; line-height: 18px; text-align: left; /*border: 1px solid red;*/ }
.footer-widgets li h2 { font-size: 1.4em; font-weight: normal; letter-spacing: 1px; line-height: 30px; text-align: left;}
.footer-archives { position: relative; top: -210px;}
.footer-widgets li.last { position: relative; top: -210px;}
h6 { font-family:Verdana, Geneva, sans-serif; font-size: 1.2em; font-weight: normal; letter-spacing: 1px; margin-top: 15px; margin-bottom: 10px; color: #fff;}
.footer-copyright { position: absolute; width: 900px; left: 50%; margin-left: -450px; top: 400px; height: 100px; font-family: Tahoma, Geneva, sans-serif; line-height: 22px; font-size: 1em; color: #fff; text-align: center; text-transform: uppercase; }
.footer-copyright a { color: #fff !important; text-decoration: none !important; }
.footer-copyright a:hover { color: #c7bd89; text-decoration: underline !important; }
.copyright { margin-top: 27px; text-transform: uppercase; display: block; color: #cc9798;}
.copyright a { color: #cc9798 !important; text-decoration: underline; }
.footer-one, .footer-two, .footer-three, .footer-four { border: 1px solid #fff; float: left;}
I have the containing footer and within the 900px x 503px container I wish that all lists float left (and under each other if it's small enough). So "Archives" would flow under "Follow Us" and if I were to put a search bar under "Testimonials" it would fit.
What can I do with my CSS to have this happen?
Why no just create a column for each side (left, center, right) and simulate it that way, well atleast I think this is what you are trying to achieve
Fiddle http://jsfiddle.net/eEwdk/
Theres another workaround that would consist in making each li element absolute positioned and calculating it's position (yeah I know it's sound redundant)
As I understand it, you want each of the li elements underneath one another. To do that you want to float the ul element to the left, not each individual li element.