Center text in image and change text colour on hover - html

I'm trying to center text within the image and have the text change colour on hover.
However the divider between the text keeps knocking out the grid and I cant get the a:hover function to work? Thanks for helping.
This is what I am trying to achieve,
http://tinypic.com/view.php?pic=az791h&s=8#.U4i1MfldUrU
http://jsfiddle.net/pR8C4/
enter code here
<div id="gallery">
<ul>
<li>
<div class="gallery-image">
<a href=""><img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
<p class="gallery-desc">top title</p>
<div class="line-separator-three"></div>
<p class="gallery-desc-bottom">bottom title</p></a>
</div>
</li>
<li>
<div class="gallery-image">
<a href=""><img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
<p></p></a>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
<li>
<div class="gallery-image">
<img src="http://lorempixel.com/output/people-q-g-320-220-1.jpg"/>
</div>
</li>
</ul>
</div>
enter code here
#gallery {
width:100%;
margin-right:auto;
margin-left:auto;
margin-top:45px;
position:relative;
-webkit-transform: translateZ(0);
}
#gallery ul {
list-style:none;
margin:0;
padding:0;
}
#gallery ul li {
overflow:hidden;
width: 30%;
margin:1.66%;
float:left;
}
#gallery li a {
position:relative;
display:block;
}
#gallery ul p {
position:absolute;
z-index:2;
padding-left:20%;
top:33%;
font-size:1.5em;
font-family:'avenir';
text-align:center;
}
#gallery ul a {
color:#fff;
}
.gallery li a:hover{
color:#FF8000;
}
#gallery ul img {
position: relative;
z-index:1;
width: 100%;
}
.line-separator-three{
width:50%;
margin-left:25%;
height:1px;
background:#F5F5F5;
border-bottom:1px solid #F5F5F5;
margin-top:20px;
margin-bottom:20px;
position:absolute;
z-index:3;
}
enter code here

For the :hover effect you just have to change the class-selector .gallery li a:hover into an id-selector #gallery li a:hover.

Related

flex box keep one gap after wrap [duplicate]

This question already has answers here:
Mystery white space underneath image tag [duplicate]
(3 answers)
Closed 4 years ago.
for some unknown reason i am getting this gap between the images after the wrap
see the sample code here:
https://codepen.io/mohammad-hossein-amri/pen/NEpzro
but the result i want should be like this
i tried almost everything and still the gap exist. somehow this extra space is getting added between the images after wrap
html, body{
background: #fff;
padding:0; margin:0;
height:100%;
}
ul#flex-container{
list-style-type: none;
margin:0; padding: 0;
display: flex;
flex-wrap: wrap;
}
ul li{
margin:0; padding: 0;
flex-grow: 1;
width:250px;
color: #fff;
font-size: 2.2em;
position: relative;
}
ul li img{
width: 100%;
}
a{
margin: 0;
padding: 0;
}
<div>
<ul id="flex-container">
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1532304887200-8db8cf689891?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9c00cde864c07aaffc35fb0b5567015e&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1484849764956-0988adac7e5c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=81b2754a46f790afd076f2293820c487&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1489832049190-666d39b40b7e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=dbc2c8c1720440ddfc6618eccd9f1656&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1535966092542-fcdb19e1ea4e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=28c12f97d6789fc30a2755b983293905&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1512238701577-f182d9ef8af7?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c396959d87964c1b361672856f73c67b&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1512341875699-0b87026a8d5e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a6119da2cefcae7d1a886c7ce698abef&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
</ul>
</div>
Update
I saw others mark another question with the same answer, but that one doesn't appear in the google search because isn't related to flex. different symptoms but the same solution doesn't make questions duplicate of each other!
Set font-size: 0; and the whitespace-only nodes won't take any space:
html, body{
background: #fff;
padding:0; margin:0;
height:100%;
}
ul#flex-container{
list-style-type: none;
margin:0; padding: 0;
display: flex;
flex-wrap: wrap;
}
ul li{
margin:0; padding: 0;
flex-grow: 1;
width:250px;
color: #fff;
font-size: 0;
position: relative;
}
ul li img{
width: 100%;
}
a{
margin: 0;
padding: 0;
}
<div>
<ul id="flex-container">
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1532304887200-8db8cf689891?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9c00cde864c07aaffc35fb0b5567015e&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1484849764956-0988adac7e5c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=81b2754a46f790afd076f2293820c487&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1489832049190-666d39b40b7e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=dbc2c8c1720440ddfc6618eccd9f1656&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1535966092542-fcdb19e1ea4e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=28c12f97d6789fc30a2755b983293905&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1512238701577-f182d9ef8af7?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c396959d87964c1b361672856f73c67b&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
<li>
<a href="">
<img src="https://images.unsplash.com/photo-1512341875699-0b87026a8d5e?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a6119da2cefcae7d1a886c7ce698abef&auto=format&fit=crop&w=500&q=60" alt="">
</a>
</li>
</ul>
</div>
Give a margin-bottom to each li.
ul li {
margin-bottom: 5px;
}

CSS3 - Display div h3 elements horizontally on hover with absolute position

I am trying to display h3 elements of parent div on hover horizontally,
as shown in screenshot below:
If I try position: absolute, all the h3 elements are collapsing, which results in another issue: I am not able to hover and get the list of h3, as they are collapsed.
codepen url :https://codepen.io/divyar34/pen/PpjrYO
HTML:
<ul>
<li>
aaa
<div>
<div>
<h3>111</h3>
<ul>
<li>zz1</li>
<li>zz2</li>
</ul>
</div>
<div>
<h3>1112</h3>
<ul>
<li>zz11</li>
<li>zz21</li>
</ul>
</div>
<div>
<h3>1113</h3>
<ul>
<li>zz1</li>
<li>zz2</li>
</ul>
</div>
</div>
</li>
<li>
bb
<div>
<div>
<h3>2220</h3>
<ul>
<li>yy</li>
<li>yyyy</li>
</ul>
</div>
<div>
<h3>2221</h3>
<ul>
<li>yy1</li>
<li>yyyy1</li>
</ul>
</div>
</div>
</li>
<li>
cc
<div>
<div>
<h3>3330</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
<div>
<h3>3331</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
<div>
<h3>3332</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
<div>
<h3>3333</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
</div>
</li>
</ul>
CSS:
a{
text-decoration:none;
padding: 5px;
border-radius: 10px;
color:white;
background:rgb(0,176,240);
border:none;
}
ul li{
list-style-type:none;
display:inline;
cursor:pointer;
float: left;
width: auto;
padding-left: 6px;
}
ul li:hover a{
background:orange;
}
ul li:hover ul{
width: 100%;
visibility: visible;
}
ul li ul{
display:block;
padding-left:5px;
padding-top:5px;
visibility: hidden;
position: absolute;
left: 0;
line-height: 40px;
}
div ul{
width:100%
}
ul li div{
visibility: hidden;
position:absolute;
}
ul li div div ul{
display:none;
}
ul li:hover div{
visibility: visible;
}
ul li div div{
display:block;
}
ul li ul li div div h3{
display:inline;
text-decoration:none;
padding: 5px;
border-radius: 10px;
color:white;
background:rgb(0,176,240);
border:none;
}
MAJOR EDITS: to accommodate the OP's added info on the issue
First of all, you are using a lot of nested div and ul, so you should consider using classes to avoid unnecessary confusion. Alternatively, If using classes affects some functionalities, then make use of CSS Selectors, instead.
Run the working snippet below, or
Use this JSFiddle if you want to play around, further.
/* New plus Modified CSS */
/*General CSS*/
li{
list-style-type:none;
display:inline;
cursor:pointer;
float: left;
width: auto;
padding-left: 6px;
}
li a{
text-decoration:none;
padding: 5px;
border-radius: 10px;
color:white;
background:rgb(0,176,240);
border:none;
}
li a + div div,
h3 + ul li {
border: solid 1px grey;
display: inline-block;
margin: 10px 2px;
padding: 0 10px;
}
li a + div,
h3 + ul {
padding-left:5px;
padding-top:5px;
position: absolute;
left: 0;
line-height: 40px;
visibility: hidden;
}
/*END General CSS*/
/*Hover CSS*/
li:hover a{
background:orange;
}
li:hover a + div,
li a + div div:hover h3 + ul {
visibility: visible;
}
/*END Hover CSS*/
/* END New plus Modified CSS */
<ul>
<li>
aaa
<div>
<div>
<h3>111</h3>
<ul>
<li>zz1</li>
<li>zz2</li>
</ul>
</div>
<div>
<h3>1112</h3>
<ul>
<li>zz11</li>
<li>zz21</li>
</ul>
</div>
<div>
<h3>1113</h3>
<ul>
<li>zz1</li>
<li>zz2</li>
</ul>
</div>
</div>
</li>
<li>
bb
<div>
<div>
<h3>2220</h3>
<ul>
<li>yy</li>
<li>yyyy</li>
</ul>
</div>
<div>
<h3>2221</h3>
<ul>
<li>yy1</li>
<li>yyyy1</li>
</ul>
</div>
</div>
</li>
<li>
cc
<div>
<div>
<h3>3330</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
<div>
<h3>3331</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
<div>
<h3>3332</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
<div>
<h3>3333</h3>
<ul>
<li>ccccc</li>
<li>dddd</li>
</ul>
</div>
</div>
</li>
</ul>

Drop down menu under slide show

I have drop down menu which use css for acting like menu :-
#primary_nav_wrap
{
background:url("../img/footer_lodyas.png")no-repeat center center fixed;
display:inline-block;
width:800px;
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
margin:0;
padding:0
}
#primary_nav_wrap ul a
{
display:block;
color:black;
text-decoration:none;
font-weight:bold;
font-size:15px;
line-height:50px;
padding:0 15px;
font-family:yekan,montserratAltenates;
}
#primary_nav_wrap ul li
{
position:relative;
display:inline-block;
float:right;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:rgba(255, 153, 0, 0.7);
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary_nav_wrap ul ul li
{
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
.slidshow_container{
max-width:800px;
position:relative;
margin:0;
padding:0;
}
.mySlides{
position:relative;
margin:0;
padding:0;
}
.numbertext{
font-family:yekan,montserratAltenates;
font-size:15px;
position:absolute;
padding:10px;
color:white;
}
.prev,.next{
cursor:pointer;
position:absolute;
padding:10px;
color:white;
margin:auto;
top:150px;
font-size:30px;
border-radius:0px 3px 3px 0px;
}
.next:hover{
background:rgba(40,40,40,0.8);
border-radius:3px 0px 0px 3px;
}
.prev:hover{
background:rgba(40,40,40,0.8);
}
.next{
right:0;
}
.mySlides .text{
font-family:yekan,montserratAltenates;
font-size:15px;
position:absolute;
bottom:0px;
padding:20px;
margin-bottom:5px;
width:800px;
text-align:center;
color:white;
background:rgba(35, 35, 35, 0.60);
overflow:hidden;
}
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item">Home</li>
<li>
Category
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>
Contact us
</li>
<li>
About us
</li>
</ul>
</nav>
<br style="clear:both;" />
<div class="slidshow_container">
<div class="mySlides fade">
<div class="numbertext">1 / 4</div>
<img src="~/Content/img/slideshow/image_1.jpg" style="width:100%;height:400px" />
<div class="text">image 1</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 4</div>
<img src="~/Content/img/slideshow/image_2.jpg" style="width:100%;height:400px" />
<div class="text">image 2</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 4</div>
<img src="~/Content/img/slideshow/image_3.jpg" style="width:100%;height:400px" />
<div class="text">image 3</div>
</div>
<div class="mySlides fade">
<div class="numbertext">4/ 4</div>
<img src="~/Content/img/slideshow/image_4.jpg" style="width:100%;height:400px" />
<div class="text">image 4</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
But when I move the mouse over the category menu the blow list get under the image of slide menu like image below:-
So how can I solve this problem ?
z-index will fix your problem,
The z-index property specifies the stack order of an element.
An element with greater stack order is always in front of an element
with a lower stack order.
Note: z-index ONLY works on positioned elements (position:absolute,
position:relative, or position:fixed).
Syntax :
z-index: auto|number|initial|inherit;
Initial value: auto
Applies to positioned elements
Inherited no
https://developer.mozilla.org/en/docs/Web/CSS/z-index
#primary_nav_wrap
{
background:url("../img/footer_lodyas.png")no-repeat center center fixed;
display:inline-block;
width:800px;
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
margin:0;
padding:0
}
#primary_nav_wrap ul a
{
display:block;
color:black;
text-decoration:none;
font-weight:bold;
font-size:15px;
line-height:50px;
padding:0 15px;
font-family:yekan,montserratAltenates;
}
#primary_nav_wrap ul li
{
position:relative;
display:inline-block;
float:right;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:rgba(255, 153, 0, 0.7);
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0;
/* Here Put z-index*/
z-index:9999;
}
#primary_nav_wrap ul ul li
{
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
.slidshow_container{
max-width:800px;
position:relative;
margin:0;
padding:0;
}
.mySlides{
position:relative;
margin:0;
padding:0;
}
.numbertext{
font-family:yekan,montserratAltenates;
font-size:15px;
position:absolute;
padding:10px;
color:white;
}
.prev,.next{
cursor:pointer;
position:absolute;
padding:10px;
color:white;
margin:auto;
top:150px;
font-size:30px;
border-radius:0px 3px 3px 0px;
}
.next:hover{
background:rgba(40,40,40,0.8);
border-radius:3px 0px 0px 3px;
}
.prev:hover{
background:rgba(40,40,40,0.8);
}
.next{
right:0;
}
.mySlides .text{
font-family:yekan,montserratAltenates;
font-size:15px;
position:absolute;
bottom:0px;
padding:20px;
margin-bottom:5px;
width:800px;
text-align:center;
color:white;
background:rgba(35, 35, 35, 0.60);
overflow:hidden;
}
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item">Home</li>
<li>
Category
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>
Contact us
</li>
<li>
About us
</li>
</ul>
</nav>
<br style="clear:both;" />
<div class="slidshow_container">
<div class="mySlides fade">
<div class="numbertext">1 / 4</div>
<img src="~/Content/img/slideshow/image_1.jpg" style="width:100%;height:400px" />
<div class="text">image 1</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 4</div>
<img src="~/Content/img/slideshow/image_2.jpg" style="width:100%;height:400px" />
<div class="text">image 2</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 4</div>
<img src="~/Content/img/slideshow/image_3.jpg" style="width:100%;height:400px" />
<div class="text">image 3</div>
</div>
<div class="mySlides fade">
<div class="numbertext">4/ 4</div>
<img src="~/Content/img/slideshow/image_4.jpg" style="width:100%;height:400px" />
<div class="text">image 4</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>

Hover on unusal nav bar (ONLY CSS)

I want to make a navigation bar. I supposed a big block would be shown when i hover a the nav bar. However, it didn't work.
This is my html code.
<div id="outerContainer">
<div id="header">
<a id="logo" href="#"><img src="#"></a>
<div id="nav">
<div class="selectors">aaa</div>
<div class="selectors">bbb</div>
<div class="selectors">ccc</div>
<div class="selectors">ddd</div>
</div>
</div>
<div id="innerContainer">
<div class="navHidden"></div>
<div class="navHidden"></div>
<div class="navHidden"></div>
<div class="navHidden"></div>
<div id="content"></div>
</div>
And, this is my css.
#nav{
position:relative;
float:left;
width:600px;
padding-left:30px;
padding-top:25px;
}
.selectors{
width:150px;
position:relative;
float:left;
margin:0;
z-index:10px;
}
.selectors:hover{border-bottom-color:silver;background-color:silver;}
.navHidden{
width:760px;
height:100px;
background-color:silver;
position:absolute;
z-index:10;
display:none;
visibility:hidden;
}
I want the web become as follow:
|.selectors |.selectors | .selectors | .selectors |
| navHidden .....(only shown when hover)......|
I can only allowed to use html and css, because this is homework.
Thanks.
Your code was adapted so now your have desired layout. But it is NOT PERFECT I did not remove excess rules. Do your homework by yourself
HTML
<div id="header">
<a id="logo" href="#"><img src="#"></a>
<div id="nav">
<div class="selectors">
aaa
<div class="navHidden">Lorem ipsum text</div>
</div>
<div class="selectors">
bbb
<div class="navHidden">Lorem ipsum text</div>
</div>
<div class="selectors">
ccc
<div class="navHidden">Lorem ipsum text</div>
</div>
<div class="selectors">
ddd
<div class="navHidden">Lorem ipsum text</div>
</div>
</div>
</div>
CSS
#nav{
position:relative;
float:left;
width:600px;
padding-left:30px;
padding-top:25px;
}
.selectors{
width:150px;
position:relative;
float:left;
margin:0;
z-index:10px;
}
.selectors:hover{
border-bottom-color:silver;
background-color:silver;
}
.navHidden{
width:760px;
height:100px;
background-color:silver;
position:absolute;
z-index:10;
display:none;
top: 100%;
left: 0;
}
.selectors:hover .navHidden {display: block;}
Try this way to create your navigation.
<style>
ul, li {list-style: none; padding: 0; margin: 0; float: left;}
li a{display: block; width: 100px; height: 40px;}
li a:hover{display: block; width: 100px; height: 40px; background: red;}
li ul {display: none;}
li:hover ul {display: block;}
</style>
</head>
<ul id="nav">
<li class="selectors">aaa</li>
<li class="selectors">bbbb
<ul id="innerContainer">
<li class="navHidden">222</li>
</li>
</ul>
</li>
</ul>

How do i solve the issue of position of <ul>?

i created a style called "topbar" using css.
The code are as follows:
.topbar:hover ul{ display: inline;}
.topbar {
float: left;
margin-left: 20px;
margin-right: 20px;
font-family:"Georgia";
}
.topbar ul {
display: none;
top:30px;
position: absolute; border-style:solid;
border-width:1px; background-color:white;}
}
.clear {
clear: both;
}
then i went to create a ul "grid" and allows mouse hover enlarge of images
ul.grid, ul.grid > li {
margin: 0;
padding: 0;
}
ul.grid {
}
ul.grid > li {
float: left;
list-style-type: none;
text-align: center;
font-family:"Georgia", serif;
padding-top:50px;
padding-bottom:25px;
padding-right:25px;
padding-left:0px;
}
ul img:hover { width: 200px; height: 250px; }
my html code:
<body>
<div class="topbar">
<p>Title</p>
<ul>
<li>A-Z</li>
<li>Z-A</li>
</ul>
</div>
<div class="topbar">
<p>Genre</p>
<ul>
<li>Action</li>
<li>Comedy</li>
<li>Animation</li>
<li>Horror</li>
<li>Drama</li>
</ul>
</div>
<div class="clear"></div>
<br />
<div id="videos">
<ul class="grid">
<li>
<p class="image"><img src="http://3.bp.blogspot.com/-AGAaic1-yrM/TcWmj77lHzI/AAAAAAAAAkQ/K6zzSk1WgUY/s1600/thor-movie-poster-1.jpg" alt="Thor" width="175" height="200" /></p>
<p class="name">Thor</p>
<p class="genre">Action</p>
<p class="format">DVD</p>
<p class="year">2011</p>
</li>
<li>
<p class="image"><img src="http://www.galacool.com/wp-content/uploads/2010/02/hangover2.jpg" alt="Hangover" width="175" height="200" /></p>
<p class="name">Hangover</p>
<p class="genre">Comedy</p>
<p class="format">DVD</p>
<p class="year">2009</p>
</li>
</ul>
</div>
</body>
Why do i have a left unwanted space beside my "thor" movie image?
The left space must be the indentation of the List where you are putting them. Ideally, to remove this left-indentation, you should set both padding and margins to "0" for the "UL".
This small piece of code works perfectly in this context:
CSS
#navcontainer ul
{
margin: 0;
padding: 0;
list-style-type: none;
}
HTML
<div id="navcontainer">
<ul>
<li>Milk
<ul>
<li>Goat</li>
<li>Cow</li>
</ul>
</li>
<li>Eggs
<ul>
<li>Free-range</li>
<li>Other</li>
</ul>
</li>
</ul>
</div>