Trying to center a ul list in a container inside... sprites in li a - html-lists

Hello i am developing a web site.... its my second one, and i am trying to center a ul inside a div
i want to place icons in anchor tags and use background positioning for sprite use.... the thing is how can i set to center the ul inside the div or inside the ul ...
example of my code here:
http://jsfiddle.net/kowen/wAdf3/1/
here is the code: (html)
<div id="container">
<ul>
<li><a class="fbicon" href="#">hola 1</a>
</li>
<li><a class="twttricon" href="#">hola 2</a>
</li>
<li><a class="sndcloudicon" href="#">hola 3</a>
</li>
<li><a class="emailicon" href="#">hola 4</a>
</li>
</ul>
and css:
#container {
width: 400px;
height:400px;
text-align: center;
background-color:gray;
}
#container ul {
display: inline-block;
}
#container li {
/* float: left;*/
height: 33px;
line-height: 30px;
text-indent:-999em;
}
#container li a {
width:32px;
height:32px;
background-image:url(http://www.testcloud.com.ar/social-icons.png);
}
a.fbicon {
background-position:-5px center;
}
a.twttricon {
background-position:-42px center;
}
a.sndcloudicon {
background-position:-111px center;
}
a.emailicon {
background-position:-148px center;
}
i have tried a few recipes but no clue how can i do that....
how can i get the a displayed as a block so it can be shown the full icon on screen???
thanks in advance for your help.
Salutations

Related

Padding messes up flexbox alignment

I am trying to have two items as links in the top right corner of the page.
I posted my code on codepen for a visual example. Whenever I add padding for the visit button the about goes up on the page.
CSS:
.navigation {
display: flex;
justify-content: space-between;
align-content: center;
&-list {
display: flex;
align-self: center;
list-style: none;
font-size: 2rem;
}
&-item {
&-visit {
background-color: $color-tertiary;
padding: 2rem;
}
}
}
Html:
<div class="container">
<navigation class="navigation">
<h1 class="porto">Porto</h1>
<ul class="navigation-list">
<li class="navigation-item">About</li>
<li class="navigation-item navigation-item-visit">Visit</li>
</ul>
</navigation>
</div>
Try removing the height in &-item and padding-bottom in &-visit.

How to change drop-down to drop-up menu

I guess I am not the first one asking this question but I am at loss and have no idea how to do this. (there is a banner above the menu but I want to keep this picture private) What should I change in this css so the menu can go upward? Please help I need it for a project and the deadline is today till midnight.
#charset "utf-8";
#menu {
padding: 0;
margin: 0 auto;
width: 1010px;
}
#menu ul {
padding:0;
margin:0;
line-height:50px;
}
#menu li {
margin:0;
padding:0;
list-style:none;
float:left;
position:relative;
background:#F00;
}
#menu ul li a {
text-align:center;
font-family:"Times New Roman", Times, serif;
font-style:oblique;
text-decoration:none;
height: 50px;
width: 200px;
display: block;
color: #FFF;
border: 1px solid #FFF;
text-shadow: 1px 1px 1px #000;
}
#menu ul ul {
position: absolute;
top: 52px;
visibility: hidden;
}
#menu ul li:hover ul{
visibility:visible;
}
#menu li:hover {
background:#999;
}
<html><head>
</head>
<body bgcolor="#000" leftmargin="50px" rightmargin="50px">
<div id="menu">
<ul>
<li><a><font size="+3">Paranoja</font></a>
<ul>
<li><a class="smoothScroll" href="#opis etiudy">Opis etiudy</a></li>
<li><a class="smoothScroll" href="#pomysl">Skąd się wziął pomysł etiudy</a></li>
<li><a class="smoothScroll" href="#inspiracje">Insiracje</a></li>
<li><a class="smoothScroll" href="#obejrzyj">Obejrzyj "Paranoję"</a></li>
<li><a class="smoothScroll" href="#caly film">Link do całego filmu</a></li>
</ul>
</li>
<li><a><font size="+3">Obsada</font></a>
<ul>
<li><a class="smoothScroll" href="#aktorzy">Aktorzy</a></li>
<li><a class="smoothScroll" href="#tworcy">Twórcy</a></li>
</ul>
</li>
<li><a><font size="+3">Reżyser</font></a>
<ul>
<li><a class="smoothScroll" href="#o mnie">O mnie</a></li>
</ul>
</li>
<li><a><font size="+3">Galeria</font></a>
<ul>
<li><a class="smoothScroll" href="#kadry">Kadry z filmu</a></li>
<li><a class="smoothScroll" href="#making">Making of</a></li>
</ul>
</li>
<li><a><font size="+3">Kontakt</font></a>
<ul>
<li><a class="smoothScroll" href="#mail">Email</a></li>
<li><a class="smoothScroll" href="#fb">Media społecznościowe</a></li>
</ul>
</li>
</ul>
</body></html>
Actually, you only need to make a small change. When you set the ul top value, you can just use bottom instead. This will cause the bottom of the drop down to align with the top of the menu button.
#menu ul ul {
position: absolute;
bottom: 52px;
visibility: hidden;
}
Here is a working example

please look at my code .... show ul after < li>< a >click event -please help -what am I doing wrong

Can someone please take a look at my code and see what I am doing wrong...
I'm a beginner jquery person and
I tried reading all the forum post and implementing them my self and I still get errors... this is taking me two days and I'm about to kill my laptop
thanks so much in advance,
~ grace
$(document).ready(function() {
//parent. on click anchor
$('.tab').on('click', '.clk', function(event) {
event.stopPropagation();
//Find the child by traversing
$(this).closest('.clk').find('.reveal').slideToggle();
//Show the child
});
});
body {
width: 350px;
margin: 0 auto;
}
h1 {
font-size: 1em;
color: #FF7F50;
}
.tbCont {
/* width: 100%;float:left; this works too*/
overflow: hidden;
border: 1px solid red;
text-align: center;
}
ul {
padding-left: 0;
}
li {
list-style: none;
display: inline-block;
zoom: 1;
width: 90%;
}
.cHolder {
display: none;
}
/*hides related content*/
.reveal {
width: 100%;
background-color: pink;
display: inline-block;
zoom: 1;
border-bottom: 2px solid #aaa;
}
.reveal span {
float: left;
width: 40%;
margin: 10px;
}
.reveal img {
float: right;
width: 40%;
height: 40%;
margin: 10px;
background-color: #fff;
}
a {
width: 100%;
text-align: left;
border-style: none;
border-bottom: 2px solid #aaa;
background-color: white;
font-size: 2em;
color: #aaa;
display: block;
text-decoration: none;
}
a:hover {
color: orange;
border-bottom: 2px solid orange;
}
a:active {
color: #7FFFD4;
border-bottom: 2px solid #7FFFD4;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
</head>
<body>
<div class="tbCont">
<h1>Title</h1>
<ul class="tab">
<li>
Tab Title
<ul class="cHolder">
<li class="reveal">
<span>copy here Lorem Ipsum is simply dummy text of the printing and typesetting industry. </span>
<img/>
</li>
</ul>
</li>
<li>
Tab Title
<ul class="cHolder">
<li class="reveal">
<span>copy here.</span>
<img/>
</li>
</ul>
</li>
<li>
Tab Title
<ul class="cHolder">
<li class="reveal">
<span>copy here</span>
<img/>
</li>
</ul>
</li>
<li>
Tab Title
<ul class="cHolder">
<li class="reveal">
<span>copy here</span>
<img/>
</li>
</ul>
</li>
<li>
Tab Title
<ul class="cHolder">
<li class="reveal">
<span>copy here</span>
<img/>
</li>
</ul>
</li>
</ul>
</div>
<!-- End your code here -->
</body>
</html>
I tried to correct in this fiddle, look if this helps :
http://jsfiddle.net/h9u2g6bu/
Notice display:none should be applied to what you want to toggle, i.e. .cHolder .reveal instead of .cHolder :
.cHolder .reveal {
display: none;
}

Images on nav bar before each link

Right, so I have made a navigation bar and I want to add images before each link, I know I can use a.header:before but I need different images for each link, a house for home, spanner for spec and so on. What is the simplest way of doing this? Is there a way without creating a div for each one and styling them individually?
For a preview of the page so far with the nav - http://zimxtrial.ukbigbuy.com/
One more thing - here is part of the css:
#header-nav {
background-color: #FFFFFF;
height: 80px; height: 8.0rem;
width: 100%;
position: absolute;
top: 50px;
}
.header-nav-center {
height: 80px; height: 8.0rem;
text-align: center;
position: relative;
top: 0px;
width: 500px; width: 50.0rem;
margin-left: auto;
margin-right: auto;
}
.header-nav-center ul {
margin: 0;
}
.header-nav-center ul li {
list-style: none;
margin: 0 35px 0 0;
display: inline;
}
a.header {
line-height: 80px; line-height: 8.0rem;
font-size: 17px; font-size: 1.7rem;
}
And HTML:
<div id="home">
<div id="header-nav">
<div id="hr-nav-top-container">
<hr class="nav" />
</div>
<div id="logo"></div>
<div class="header-nav-center">
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li><a class="header" href="#features">Features</a>
</li>
<li><a class="header" href="#specification">Specification</a>
</li>
<li><a class="header" href="#contact-us">Contact Us</a>
</li>
</ul>
</div>
<div id="pre-order"></div>
<div id="hr-nav-bottom-container">
<hr class="nav" />
</div>
</div>
</div>
Can I add something like:
a.header.home:before {
background: url('../images/home-logo.png') center center no-repeat;
}
Not that exactly but something like it?
You could make ids for each link and add the ids to the desired link img

Center a horizontal menu with an image in the middle

I am trying to center my menu bar with my logo in the middle. right now everything is floating but it wont center to the middle of the page. Also when it is centered i need the background image that i placed on the left and right side of the logo to resize according to the width of the page - here is a link to how it looks live - Menu Test
on my website i still have the original menu I created where I placed the logo behind the menu bar and set a longer width so that the background would stretch but it won't auto adjust because of it.... Current Menu
I know my code is not perfect so please just bear with me
html
<div id="access">
<div class="menu-container">
<ul id="menu-left" class="menu">
<li class="menu-item">
Home
</li>
<li class="menu-item">
About
</li>
<li class="menu-item">
Services
</li>
</ul><!--END of menu-navigation-left-->
<ul id="menu-center">
<li class="menu-item">
<img src="images/logo.png" alt="Menu">
</li>
</ul> <!--close div center-->
<ul id="menu-right" class="menu">
<li class="menu-item">
Blog
</li>
<li class="menu-item">
Contact
</li>
<li class="menu-item">
Portfolio
</li>
</ul><!--END of menu-navigation-left-->
</div><!--END of menu-navigation-container-->
</div><!--END of access-->
css
header {
position:fixed;
}
#access {
width:100%;
overflow:hidden;
left:50%;
}
#access ul.menu{
display: inline-block;
}
#access ul {
}
#access ul a{
display:block;
}
#access ul#menu-left {
height:120px;
background-image:url(../images/menu.png);
}
#access ul#menu-center {
height:120px;
}
#access ul#menu-right {
height:120px;
background-image:url(../images/menu.png);
}
ul, li {
margin:0px;
padding:0px;
list-style:none;
float:left;
display:block;
}
#access a {
display: block;
font-size: 16px;
line-height: 15px;
padding: 13px 10px 12px 10px;
text-transform: titlecase;
text-decoration: none;
font:"Mc1regular", Arial, sans-serif;
}
a:link{
color:#fff;
}
a:visited{
color:#fff;
}
This should sort out your alignment issues.. just replace with your specs. I would just have one menu and centre it.
PLEASE NOTE, YOUR HEADER POSITION IS FIXED> position:relative would be better..
div.container {
width: 1160px;
margin: auto;
margin-top: -1;
margin-bottom: -1;
padding: 0;
padding-top: 10px;
background-color: #2d2d2d;
}
div.box {
margin: auto;
margin-top: 20px;
margin-bottom: 20px;
padding: 10px;
padding-bottom: 20px;
border: solid 1px #A29060;
background-color: #000;
overflow: hidden;
width: 940px;
}
div.top {
text-align: left;
margin: auto;
margin-left: 20px;
padding-top: 12px;
padding-bottom: 11px;
font-weight: normal;
font-size: 14px;
overflow: hidden;
width: 980px;
text-transform: uppercase;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
float: left;
padding-right: 20px;
}
a {
display: block;
color: #a29060;
text-decoration: none;
}
<div class="container">
<div class="box">
<div class="top">
<ul >
<li>Contact</li>
<li>Policies</li>
<li><img class="logo" src="images/logo.jpg" alt="logo" /></li>
<li>Policies</li>
</ul>
</div>
see this fiddle
http://jsfiddle.net/yvytty/RJ4Yp/
You can also have a look at this (it's not finished) but it has the basic layout sorted, menus etc
https://www.yve3.com/index.html
This is also a link to a great forum, HTML.net. They give you good opinions of your site and have a lot of expertise (just like here)
http://www.html.net/forums/

Resources