Images don't align on <li> - html

I am trying to get this images on the same line but the images bump.
This is the code:
HTML
<div class="first-list">
<ul>
<li><a style="text-decoration:none;" href="http://trendwatching.com/freepublications/?utm_campaign=2016%20Global%20Consumer%20Trend%20Events&utm_content=Footer-FP&utm_source=email" target="_blank">
<img src="#" />TW:FREE
</a>
</li>
<li><a style="text-decoration:none;" href="http://spotters.trendwatching.com/?utm_campaign=2016%20Global%20Consumer%20Trend%20Events&utm_content=Footer-TW%3AIN&utm_source=email" target="_blank">
<img src="#" />TW:IN
<a/>
</li>
<li><a style="text-decoration:none;" href="http://trendwatching.com/about/" target="_blank">
<img src="#" />TW:ABOUT
</a>
</li>
</ul>
</div>

In order to get the images on one line, use css property display: inline, it will align your items in single line

I got you solution, added float=left in li elements, just increase width in css in case they are not fitting:
<div class="first-list">
<ul>
<li style="float:left;list-style-type: none;">
<a style="text-decoration:none;" href="http://trendwatching.com/freepublications/?utm_campaign=2016%20Global%20Consumer%20Trend%20Events&utm_content=Footer-FP&utm_source=email" target="_blank">
<img src="#" />TW:FREE
</a>
</li>
<li style="float:left;list-style-type: none;">
<a style="text-decoration:none;" href="http://spotters.trendwatching.com/?utm_campaign=2016%20Global%20Consumer%20Trend%20Events&utm_content=Footer-TW%3AIN&utm_source=email" target="_blank">
<img src="#" />TW:IN
</a>
</li>
<li style="float:left;list-style-type: none;"><a style="text-decoration:none;" href="http://trendwatching.com/about" target="_blank">
<img src="#" />TW:ABOUT
</a>
</li>
</ul>
</div>
<style>
div{
width:1080px;
}
</style>

Related

Why isn't the flex-direction going from row to column

I'm coding using the Front-ENd Web Development [The Big Nerd Ranch Guide] book to help me better understand css and javascript. There's a project where I'm learning how to use media queries and im suppose to changed the flex-direction property from a row to a column. I've copied the code as its shown and for some odd reason the code doesn't change the direction. It Follows everything before and after that piece of code. I'm hoping a extra pair of eyes can help me spot where I went wrong and help me understand media-queries & flexbox better.
<main class="main-content">
<ul class="thumbnail-list">
<li class="thumbnail-item">
<a href="#">
<img src="img/otter1.jpg" alt="Barry The Otter" class="thumbnail-image">
<span class="thumbnail-title">Barry</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter2.jpg" alt="Robin The Otter" class="thumbnail-image">
<span class="thumbnail-title">Robin</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter3.jpg" alt="Maurice The Otter" class="thumbnail-image">
<span class="thumbnail-title">Maurice</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter4.jpg" alt="Lesley The Otter" class="thumbnail-image">
<span class="thumbnail-title">Lesley</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter5.jpg" alt="Barbara The Otter" class="thumbnail-image">
<span class="thumbnail-title">Barbara</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter1.jpg" alt="Barry The Otter" class="thumbnail-image">
<span class="thumbnail-title">Barry</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter2.jpg" alt="Robin The Otter" class="thumbnail-image">
<span class="thumbnail-title">Robin</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter3.jpg" alt="Maurice The Otter" class="thumbnail-image">
<span class="thumbnail-title">Maurice</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter4.jpg" alt="Lesley The Otter" class="thumbnail-image">
<span class="thumbnail-title">Lesley</span>
</a>
</li>
<li class="thumbnail-item">
<a href="#">
<img src="img/otter5.jpg" alt="Barbara The Otter" class="thumbnail-image">
<span class="thumbnail-title">Barbara</span>
</a>
</li>
</ul>
______________________________________________________________________________
CSS
#media all and (min-width: 768px){
.main-content{
flex-direction: row;
overflow: hidden;
}
.thumbnail-list{
flex-direction: column;
margin-left: 20px;
order: 0;
}
.thumbnail-item{
max-width: 260px;
}
.thumbnail-item + .thumbnail-item{
margin-top: 20px;
}
}
Add display:flex; at the top of class thumbnail-list in the css. This should solve the problem. At the moment you don't seem to be telling the css to use flexbox in the first place.

I have issue with my css

I have currently 4 widgets witch have their own sizes. I have placed them within a main div called #box I get them centered by reducing the width to about 60% and having margin left and right on auto. If I zoom out in my browser the widget blocks moves more to the left and does not stay centered.
<div id="Box"><!--Start Div Box-->
<div id="TA_certificateOfExcellence580" class="Certificate Certificate-one">
<ul id="Lnnr78SGL0" class="TA_links 4fJwNUzU0uDT">
<li id="phnjh3wZ" class="Yi5zwOy1yHP">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence654" class="Certificate Certificate-two">
<ul id="FVuBAHp" class="TA_links CPqPZ6">
<li id="dYmcZAj7eGOi" class="FKHiRxci">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence588" class="Certificate Certificate-three">
<ul id="E4oUIOq5y" class="TA_links JWgIqGH4nEMg">
<li id="R3Oc1SU8Y" class="bXEYi56LVvek">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence396" class="Certificate Certificate-four-last">
<ul id="ENh9NKezEOIt" class="TA_links j9dirUfR">
<li id="LKMj2Zk" class="Z16i8koQq">
<a target="_blank" href="https://www.tripadvisor.co.za/Attraction_Review-g312578-d2284717-Reviews-Felleng_Day_Tours-Johannesburg_Greater_Johannesburg_Gauteng.html">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2015_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
</div><!--End Div Box-->
#Box
{
background-color:#CCCCCC;
width:60%;
margin-left:auto;
margin-right:auto;
}
Image before zooming browser out
Image after zooming out
The problem is that the container of your images itself is indeed centred, but the images are aligned to the left of that container. If you gave the #box a different background color, you'd see that immediately.
Try giving the #Box element a center, and then center the inside elements as well.
Since you are using <div> elements, I'd go for float: left and giving each element a specific width property. I'd rather go with an inline-block element because it's easier to center, and because you only have images which are naturally inline-block, but this is not what you have implemented.
Check out this fiddle: https://jsfiddle.net/abvt8ekj/
And the snippet:
.container {
background-color: #ee55cc;
}
#Box{
background-color:#CCCCCC;
width:60%;
margin-left:auto;
margin-right:auto;
}
#Box:after {
display: block;
content: "";
clear: both;
}
.Certificate {
width: 25%;
float: left;
overflow: hidden;
}
.Certificate ul,
.Certificate li {
margin: 0;
padding: 0;
}
<div class="container">
<div id="Box"><!--Start Div Box-->
<div id="TA_certificateOfExcellence580" class="Certificate Certificate-one">
<ul id="Lnnr78SGL0" class="TA_links 4fJwNUzU0uDT">
<li id="phnjh3wZ" class="Yi5zwOy1yHP">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence654" class="Certificate Certificate-two">
<ul id="FVuBAHp" class="TA_links CPqPZ6">
<li id="dYmcZAj7eGOi" class="FKHiRxci">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence588" class="Certificate Certificate-three">
<ul id="E4oUIOq5y" class="TA_links JWgIqGH4nEMg">
<li id="R3Oc1SU8Y" class="bXEYi56LVvek">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence396" class="Certificate Certificate-four-last">
<ul id="ENh9NKezEOIt" class="TA_links j9dirUfR">
<li id="LKMj2Zk" class="Z16i8koQq">
<a target="_blank" href="https://www.tripadvisor.co.za/Attraction_Review-g312578-d2284717-Reviews-Felleng_Day_Tours-Johannesburg_Greater_Johannesburg_Gauteng.html">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2015_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
</div><!--End Div Box-->
</div>
If you don't want to specify a width to your main box, you can use the text-align property :
text-align:center;
Here's a Fiddle with a little demo : https://jsfiddle.net/valentinho14/cst30wuc/
Try instead of using the div called #box be in the center of the page, put another div inside #box1 and align that second div in the center.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
#box1{
background-color:black;
}
#box2{
margin:auto;
background-color:green;
width:50px;
height:50px;
display:block;
align:center;
}
</style>
</head>
<body>
<div id = "box1">
<div id = "box2"></div>
</div>
</body>
</html>
That did it for me, and even if you zoom in or out the div will stay in the center. Just put the images into the second div. Take care.
you can try doing it with flexbox like this it will always stay in the center!
and if you dont want the list-style-type dont forget to put padding-left:0px; to the ul's because by default ther is a padding :40px;
#Box{
display:flex;
justify-content:center;
}
<div id="Box"><!--Start Div Box-->
<div id="TA_certificateOfExcellence580" class="Certificate Certificate-one">
<ul id="Lnnr78SGL0" class="TA_links 4fJwNUzU0uDT">
<li id="phnjh3wZ" class="Yi5zwOy1yHP">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence654" class="Certificate Certificate-two">
<ul id="FVuBAHp" class="TA_links CPqPZ6">
<li id="dYmcZAj7eGOi" class="FKHiRxci">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence588" class="Certificate Certificate-three">
<ul id="E4oUIOq5y" class="TA_links JWgIqGH4nEMg">
<li id="R3Oc1SU8Y" class="bXEYi56LVvek">
<a target="_blank" href="https://www.tripadvisor.co.za">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2014_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
<div id="TA_certificateOfExcellence396" class="Certificate Certificate-four-last">
<ul id="ENh9NKezEOIt" class="TA_links j9dirUfR">
<li id="LKMj2Zk" class="Z16i8koQq">
<a target="_blank" href="https://www.tripadvisor.co.za/Attraction_Review-g312578-d2284717-Reviews-Felleng_Day_Tours-Johannesburg_Greater_Johannesburg_Gauteng.html">
<img src="https://www.tripadvisor.co.za/img/cdsi/img2/awards/CoE2015_WidgetAsset-14348-2.png" alt="TripAdvisor"
class="widCOEImg" /></a>
</li>
</ul>
</div>
</div><!--End Div Box-->

How to catch this nth-child() with css

I have this html code
<ul>
<div id="consolidation-checkboxes-container" class="consolidation-checkboxes container" style="height: 104px;">
<a href="" class="consolidation-link" target="_blank">
<li>one</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>two</li>
</a>
<a href="" class="consolidation-link bordered" target="_blank">
<li>three</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>four</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>five</li></a>
<a href="" class="consolidation-link" target="_blank">
<li>six</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>seven</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>eight</li>
</a>
</div>
</ul>
I would like the seventh li not have bullet.Is this possible to be done with css, because I am not allowed to change the html
If your html is the one you provide you can use the following code:
ul div a:nth-child(7) li {
list-style-type: none;
}
<ul>
<div id="consolidation-checkboxes-container" class="consolidation-checkboxes container" style="height: 104px;">
<a href="" class="consolidation-link" target="_blank">
<li>one</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>two</li>
</a>
<a href="" class="consolidation-link bordered" target="_blank">
<li>three</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>four</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>five</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>six</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>seven</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>eight</li>
</a>
</div>
</ul>
Additional as mention in comments ul element can only contain zero or more li elements, eventually mixed with ol and ul elements. So you can change your html mark up to be valid like:
ul li:nth-child(7) {
list-style-type: none;
}
<ul>
<li>one
</li>
<li>two
</li>
<li>three
</li>
<li>four
</li>
<li>five
</li>
<li>six
</li>
<li>seven
</li>
<li>eight
</li>
</ul>
you can also do like this to exactly catch the nth-child..
ul > div > a:nth-child(7) > li {
list-style-type: none;
}

Span tag on IE and FF

I have the following code:
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<ul id="controlsCar" class="entries nav nav-pills nav-justified">
<li data-target="#custom_carousel" data-slide-to="0">
<a href="#">
<span>
<img src="img1.png" alt="" class="img-responsive iconMenu"/>
</span>
<span>
<div class="menuCarusel">Tittle</div>
</span>
</a>
</li>
<li data-target="#custom_carousel" data-slide-to="1">
<a href="#">
<span>
<img src="img2.png" alt="" class="img-responsive iconMenu"/>
</span>
<span>
<div class="menuCarusel">Tittle1</div>
</span>
</a>
</li>
<li data-target="#custom_carousel" data-slide-to="2">
<a href="#">
<span>
<img src="img3.png" alt="" class="img-responsive iconMenu"/>
</span>
<span>
<div class="menuCarusel">Tittle3</div>
</span>
</a>
</li>
</ul>
</div>
</div>
it resizes perfectly on Safari and Chrome but I do not see any change in the image with using FireFox or IE.
Does it have to do with the SPAN TAG ? Any ideas?
Thanks

Placing a DIV in my header

I'm trying to put a linkable image into my header RIGHT underneath the phone number but its not working. My question is where do I place the div and how do I style it?
The code for me current header is:
<div class="header-right">
<div class="social">
<!--social media icons-->
<ul>
<li>
<a class="contact" href="http://" title="Contact Us"></a>
</li>
<li>
<a class="google" href="http:/" target="_blank" title="Share on Google+"></a>
</li>
<li>
<a class="facebook" href="http:/" target="_blank" title="Share on Facebook"></a>
</li>
<li>
<a class="twitter" href="http:/" target="_blank" title="Share on Twitter"></a>
</li>
</ul>
</div>
<div class="telephone">
<p class="tel">Speak with<br/>
<?php bloginfo( 'description' ); ?><br />
<small>Available 08:30 - 17:00, Mon-Fri</small>
</p>
</div>
</div>
<div class="header-right">
<div class="social">
<!--social media icons-->
<ul>
<li>
<a class="contact" href="http://" title="Contact Us"></a>
</li>
<li>
<a class="google" href="http:/" target="_blank" title="Share on Google+"></a>
</li>
<li>
<a class="facebook" href="http:/" target="_blank" title="Share on Facebook"></a>
</li>
<li>
<a class="twitter" href="http:/" target="_blank" title="Share on Twitter"></a>
</li>
</ul>
</div>
<div class="telephone">
<p class="tel">Speak with<br/>
info<br />
<div>an image</div>
<small>Available 08:30 - 17:00, Mon-Fri</small>
</p>
</div>
</div>