Dropdown menu doesn't become visible on .drop:hover - html

I'm creating a menu, where if I hover over the li class="drop", then the visibility of my #competences-dropdown should become visible, but it doesn't wanna work for some reason. Can someone please help by telling what didn't I noticed?
.drop:hover #competences-dropdown {
visibility:visible;
}
#competences-dropdown {
background-color:rgba(51,51,51,0.8);
width:100%;
padding-right:100px;
position:absolute;
z-index:3;
visibility:hidden;
-webkit-transition:1s;
display:block;
}
<div id="menu">
<ul class="navigation">
<li>Forside</li>
<li class="drop">Kompetencer</li>
<li>Om Magento</li>
<li>Teamet</li>
<li>Cases</li>
<li>Blog</li>
<li>Kontakt</li>
</ul>
</div>
<div id="competences-dropdown">
<div class="row">
<div class="col-sm-12">
<ul class="dropdown">
<li><a href="">
<h1>WEBUDVIKLING</h1>
<img class="img-responsive" src="img/dropdown/webdev.png" alt="Webdev"/>
</a></li>
<li><a href="">
<h1>DESIGN</h1>
<img class="img-responsive" src="img/dropdown/design.png" alt="Design"/>
</a></li>
<li><a href="">
<h1>MARKETING</h1>
<img class="img-responsive" src="img/dropdown/marketing.png" alt="Marketing"/>
</a></li>
</ul>
</div>
</div>
</div>

of cousre it doesn't work as your css says:
.drop:hover #competences-dropdown {
visibility:visible;
}
which means #competences-dropdown is a child of .drop, which it is not.
so the solution would be making #competences-dropdown a child of .drop as follows, and everything should work fine:
.drop:hover #competences-dropdown {
visibility:visible;
}
#competences-dropdown {
background-color:rgba(51,51,51,0.8);
width:100%;
padding-right:100px;
position:absolute;
z-index:3;
visibility:hidden;
-webkit-transition:1s;
display:block;
}
<div id="menu">
<ul class="navigation">
<li>Forside</li>
<li class="drop">
Kompetencer
<div id="competences-dropdown">
<div class="row">
<div class="col-sm-12">
<ul class="dropdown">
<li>
<a href="">
<h1>WEBUDVIKLING</h1>
<img class="img-responsive" src="img/dropdown/webdev.png" alt="Webdev"/>
</a>
</li>
<li>
<a href="">
<h1>DESIGN</h1>
<img class="img-responsive" src="img/dropdown/design.png" alt="Design"/>
</a>
</li>
<li>
<a href="">
<h1>MARKETING</h1>
<img class="img-responsive" src="img/dropdown/marketing.png" alt="Marketing"/>
</a>
</li>
</ul>
</div>
</div>
</div>
</li>
<li>Om Magento</li>
<li>Teamet</li>
<li>Cases</li>
<li>Blog</li>
<li>Kontakt</li>
</ul>
</div>

Try to use
.drop:hover {
visibility:visible;
}
Maybe you should try opacity instead of visibility
Also do put the :hover always at the end of your code like this
.example #example:hover{}
And not
.example:hover #example{}

Related

How can i make active background color for two elements in nav menu

I have a vertical navbar menu with 2 blocks.
First is nav with icons, second is text of menu.
They have a different background colors. How i can make one background color for two active nav blocks?
design of menu
<div class="menu__icons">
<ul class="menu__list">
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
</ul>
</div>
<div class="menu__text">
<ul class="menu__list">
<li><a class="menu__item" href="#">First</a></li>
<li><a class="menu__item" href="#">Second</a></li>
<li><a class="menu__item" href="#">Third</a></li>
<li><a class="menu__item" href="#">Fourth</a></li>
</ul>
</div>
</div>
https://jsfiddle.net/levan563/1g5ucmwq/2/
Well basically if you want to toggle .active and you don't want two separate markup of list.
Notice that font-awesome is for demonstration purposes only.
.menu__item {
width: 250px;
height: 50px;
text-align: left;
}
.menu__item.active {
background-color: #e9ebfd;
}
.menu__item.active .menu__icon {
background-color: #e9ebfd;
border-left: 4px solid #2c39ec;
}
.menu__item.active .menu__title {
background-color: #e9ebfd;
}
.menu__item a:hover {
text-decoration: none;
}
.menu__icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
background-color: #fafafa;
color: #2c39ec;
}
.menu__title {
display: inline-block;
padding-left: 20px;
color: #777777;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navigation-menu">
<ul class="menu__list list-unstyled">
<li class="menu__item active">
<a href="#">
<div class="menu__icon">
<i class="fa fa-tachometer-alt"></i>
</div>
<div class="menu__title">Main Dashboard</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-user"></i>
</div>
<div class="menu__title">Profile</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-bell"></i>
</div>
<div class="menu__title">Finances</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-calendar"></i>
</div>
<div class="menu__title">Titles</div>
</a>
</li>
</ul>
</nav>
Related Fiddle https://jsfiddle.net/mhrabiee/dojL9get/28/
As I understand take active class for both block's li and try to use font, svg icon or transparent background images instead of block images
.menu__list .active {
background-color: red;
}
<div class="menu__icons">
<ul class="menu__list">
<li><a class="menu__item active" href="#">
<img src="https://img.icons8.com/material/24/000000/tailoring-for-men.png">
</a></li>
</ul>
</div>
<div class="menu__text">
<ul class="menu__list">
<li><a class="menu__item active" href="#">First</a></li>
</ul>
</div>
Its doable using jQuery.
Assuming you have same number of list items in both blocks,
$(function(){
$('.menu__list li').on('click', function() {
var idx = $(this).index();
$('.menu__list li').removeClass('active');
$('.menu__list li:nth-child(' + idx + ')').addClass('active');
});
});
also add .active class in css and give needed style to li items also
.active{
/**your style**/
}
.active > a{
}
.active img{
}

How to add an image to list items in Html?

I have the following html code for a simple menu:
<div class="wHeader">
<div class="header">
<img src="header.png">
</div><!-- header ends here -->
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li class="current-item">Home</li>
<li>
Language
<ul class="sub-menu">
<li><a href=#>Lang1</a></li>
<li><a href=#>Lang2</a></li>
<li>Other ...</li>
</ul>
</li>
</ul>
</nav>
</div> <!-- menu-wrap ends here-->
The CSS style for <ul> is as follows:
.sub-menu {
width:120%;
padding:5px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
background:#808080;
}
I'm trying to put a flag image in one of the list items like this:
<li style="list-style-image: url('smallflag.png');">Lang1</li>
But so far the image is not appearing. Is there any conflict with background? Any suggestions to solve this?
.sub-menu {
width:120%;
padding:5px 0px;
position:absolute;
/*top:100%;*/
<!--left:0px;-->
z-index:-1;
/*opacity:0;*/
transition:opacity linear 0.15s;
background:#808080;
}
<div class="wHeader">
<div class="header">
<!--<img src="header.png">-->
</div><!-- header ends here -->
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li class="current-item">Home</li>
<li>
Language
<ul class="sub-menu">
<li><a href=#>Lang1</a></li>
<li><a href=#>Lang2</a></li>
<li style="list-style-image: url('http://placehold.it/20x20');">Other ...</li>
</ul>
</li>
</ul>
</nav>
</div>
The sub-menu class is hiding it and moving it to the bottom of the screen, also the picture is lost with the left:0px property.
If you comment out the top:100%, left:0 and opacity properties, the item will show with its image

align center a UL with only images [duplicate]

This question already has answers here:
How to align a <div> to the middle (horizontally/width) of the page [duplicate]
(27 answers)
Closed 6 years ago.
I have a <ul> with 6 images, no text. I can't seem to make it be in the center of the page. This is my code.
CSS
.logos{
margin:0 auto;
text-align:center;
display:table;
float: left;
}
HTML
<div class="logos" style="margin:0 auto;">
<ul class="logos">
<li class="logos"> <img src="imgs/logo1.gif"> </li>
<li class="logos"> <img src="imgs/logo2.gif"> </li>
<li class="logos"> <img src="imgs/logo3.gif"> </li>
<li class="logos"> <img src="imgs/logo4.gif"> </li>
<li class="logos"> <img src="imgs/logo5.gif"> </li>
<li class="logos"> <img src="imgs/logo6.gif"> </li>
</ul>
</div>
You need to change
.logos{
margin:0 auto;
text-align:center;
display:table;
float: left;
}
to
.logos{
margin:0 auto;
text-align:center;
display:table;
}
and the content will be in the middle of the page
Also you need to delete the div because is useless ,you set the same class to the ul and to div
Do it like this
.logo_wrapper {
width: 100%;
position: relative;
}
.logos {
position: absolute;
left: 50%;
transform: translateX(-50%);
padding: 0;
}
.logo {
display: inline-block;
margin: 0 auto;
text-align: center;
float: left;
}
<div class="logo_wrapper">
<ul class="logos">
<li class="logo">
<img src="imgs/logo1.gif">
</li>
<li class="logo">
<img src="imgs/logo2.gif">
</li>
<li class="logo">
<img src="imgs/logo3.gif">
</li>
<li class="logo">
<img src="imgs/logo4.gif">
</li>
<li class="logo">
<img src="imgs/logo5.gif">
</li>
<li class="logo">
<img src="imgs/logo6.gif">
</li>
</ul>
</div>
First of all remove the class name for div. ul and div have the same class name.
Give float:left to li
.logos{
margin:0 auto;
display:table;
}
.logos li{
float:left;
}
<div>
<ul class="logos">
<li class="logos"> <img src="imgs/logo1.gif"> </li>
<li class="logos"> <img src="imgs/logo2.gif"> </li>
<li class="logos"> <img src="imgs/logo3.gif"> </li>
<li class="logos"> <img src="imgs/logo4.gif"> </li>
<li class="logos"> <img src="imgs/logo5.gif"> </li>
<li class="logos"> <img src="imgs/logo6.gif"> </li>
</ul>
</div>

HTML Dropdown Menu: Only selected menu

Hello Stackers,
I'm feeling very noobish right now, but I can't seem to get the right "drop down" underneath a button. When I hover over the Button "ONE", I only want the correct Dropdown menu showing up there. However, They all show up when hovering.
I can't really provide the HTML since it's using CONTAO Cms.
The CSS
#header nav.mod_navigation.main ul.level_2 li a:hover {
background-color:#f9f301;
color:#ffffff;
}
#header nav.mod_navigation.main ul.level_2 li a {
background:#ffffff !important;
color:#000000 !important;
width:100%;
border-radius:0px;
margin-right:0px !important;
}
#header nav.mod_navigation.main ul.level_2 li {
background-color:#ffffff !important;
color:#000000 !important;
width:100%;
border-bottom:1px dashed #000000;
border-radius:0px;
padding:0px;
}
#header nav.mod_navigation.main > ul:hover .level_2 {
display:block;
}
#header nav.mod_navigation.main ul.level_2 {
top:170px;
position:absolute;
overflow:visible;
display:none;
margin:0;
padding:0;
background-color:#fff;
z-index:1000;
max-width:170px;
}
HTML
For the HTML you can visit JSFiddle, since it's pretty long: https://jsfiddle.net/p9y21cee/
What am I doing wrong?
Change this:
#header nav.mod_navigation.main > ul:hover .level_2 {}
to:
#header nav.mod_navigation.main li:hover .level_2 {}
#header nav.mod_navigation.main ul.level_2 li a:hover {
background-color:#f9f301;
color:#ffffff;
}
#header nav.mod_navigation.main ul.level_2 li a {
background:#ffffff !important;
color:#000000 !important;
width:100%;
border-radius:0px;
margin-right:0px !important;
}
#header nav.mod_navigation.main ul.level_2 li {
background-color:#ffffff !important;
color:#000000 !important;
width:100%;
border-bottom:1px dashed #000000;
border-radius:0px;
padding:0px;
}
#header nav.mod_navigation.main li:hover .level_2 {
display:block;
}
#header nav.mod_navigation.main ul.level_2 {
top:170px;
position:absolute;
overflow:visible;
display:none;
margin:0;
padding:0;
background-color:#fff;
z-index:1000;
max-width:170px;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<header id="header">
<div class="inside">
<div class="kopfleiste">
<h1 class="logo"><a href=
""><img alt=
"" src=
""></a></h1>
</div>
<div class="open-close" id="btnmenu">
Menü
</div>
<div id="mobile-navi" style="display: none;">
<!-- indexer::stop -->
<nav class="mod_navigation block">
<a class="invisible" href=
"privat-gewerblich.html#skipNavigation15">Navigation
überspringen</a>
<ul class="level_1" role="menubar">
<li class="first">
<a class="first" href="home-17.html" role=
"menuitem" title="">Home</a>
</li>
<li>
<a href="elektrotechnik.html" role="menuitem"
title="Leistungen">Leistungen</a>
</li>
<li class="submenu trail">
<a aria-haspopup="true" class="submenu trail" href=
"industrieelektrik.html" role="menuitem" title=
"Referenzen">Referenzen</a>
<ul class="level_2" role="menu">
<li class="sibling first">
<a class="sibling first" href=
"industrieelektrik.html" role="menuitem"
title=
"Industrieelektrik">Industrieelektrik</a>
</li>
<li class="active"><span class="active" role=
"menuitem">Privat / Gewerblich</span></li>
<li class="sibling last">
<a class="sibling last" href=
"marktanschluesse.html" role="menuitem"
title="Marktanschlüsse">Marktanschlüsse</a>
</li>
</ul>
</li>
<li>
<a href="ueber-uns-20.html" role="menuitem" title=
"Über Uns">Über Uns</a>
</li>
<li>
<a href="downloads.html" role="menuitem" title=
"Downloads">Downloads</a>
</li>
<li>
<a href="21.html" role="menuitem" title=
"Kontakt">Kontakt</a>
</li>
<li class="last">
<a class="last" href="jobs-24.html" role="menuitem"
title="Jobs">Jobs</a>
</li>
</ul><a class="invisible" id="skipNavigation15"> </a>
</nav><!-- indexer::continue -->
</div><!-- indexer::stop -->
<nav class="mod_navigation main block">
<a class="invisible" href=
"privat-gewerblich.html#skipNavigation14">Navigation
überspringen</a>
<ul class="level_1" role="menubar">
<li class="first">
<a class="first" href="home-17.html" role="menuitem"
title="">Home</a>
</li>
<li class="submenu">
<a aria-haspopup="true" class="submenu" href=
"elektrotechnik.html" role="menuitem" title=
"Leistungen">Leistungen</a>
<ul class="level_2" role="menu">
<li class="first">
<a class="first" href="elektrotechnik.html"
role="menuitem" title=
"Elektrotechnik">Elektrotechnik</a>
</li>
<li>
<a href="industrieservice.html" role="menuitem"
title="Industrieservice">Industrieservice</a>
</li>
<li>
<a href="photovoltaik.html" role="menuitem"
title="Photovoltaik">Photovoltaik</a>
</li>
<li>
<a href="waermepumpen.html" role="menuitem"
title="Wärmepumpen">Wärmepumpen</a>
</li>
<li>
<a href="marktanschluesse-32.html" role=
"menuitem" title=
"Marktanschlüsse">Marktanschlüsse</a>
</li>
<li>
<a href="service.html" role="menuitem" title=
"Service">Service</a>
</li>
<li>
<a href="planungsbuero.html" role="menuitem"
title="Planungsbüro">Planungsbüro</a>
</li>
<li class="last">
<a class="last" href="vermietung.html" role=
"menuitem" title="Vermietung">Vermietung</a>
</li>
</ul>
</li>
<li class="submenu trail">
<a aria-haspopup="true" class="submenu trail" href=
"industrieelektrik.html" role="menuitem" title=
"Referenzen">Referenzen</a>
<ul class="level_2" role="menu">
<li class="sibling first">
<a class="sibling first" href=
"industrieelektrik.html" role="menuitem" title=
"Industrieelektrik">Industrieelektrik</a>
</li>
<li class="active"><span class="active" role=
"menuitem">Privat / Gewerblich</span></li>
<li class="sibling last">
<a class="sibling last" href=
"marktanschluesse.html" role="menuitem" title=
"Marktanschlüsse">Marktanschlüsse</a>
</li>
</ul>
</li>
<li>
<a href="ueber-uns-20.html" role="menuitem" title=
"Über Uns">Über Uns</a>
</li>
<li>
<a href="downloads.html" role="menuitem" title=
"Downloads">Downloads</a>
</li>
<li>
<a href="21.html" role="menuitem" title=
"Kontakt">Kontakt</a>
</li>
<li class="last">
<a class="last" href="jobs-24.html" role="menuitem"
title="Jobs">Jobs</a>
</li>
</ul><a class="invisible" id="skipNavigation14"> </a>
</nav><!-- indexer::continue -->
<div class="mod_article first last block" id="article-56">
<div class=
"mod_rocksolid_slider first last block rsts-main rsts-direction-x rsts-type-slide rsts-skin-light rsts-no-touch"
style="">
<div class="rsts-view" style="">
<div class="rsts-crop" style=
"width: 1000px; height: 440px; transform: translateZ(0px);">
<div class="rsts-slides" style=
"transform: translate3d(0px, 0px, 0px);">
<div class=
"rsts-slide rsts-slide-image rsts-active"
style="width: 1000px; transform: translate3d(0px, 0px, 0px); top: 0px;">
<div data-rsts-type="image"><img alt=""
height="440" src=
""
style=
"display: block; width: 1000px; height: 440px; min-width: 0px; min-height: 0px; max-width: none; max-height: none; margin-top: 0px; margin-left: 0px;"
width="1000"></div>
</div>
</div>
</div><a class="rsts-prev" href="" style=
"display: none;">prev</a><a class="rsts-next" href=""
style="display: none;">next</a>
</div>
</div>
<div id="shadow" style="clear:both;"><img src=
"files/Theessen/Basic/Shadow-Slider.png"></div>
<script>
(function($){var slider=$('.mod_rocksolid_slider').last();slider.find('video[data-rsts-background],[data-rsts-type=video]video').each(function(){this.player=false;});slider.rstSlider({"type":"slide","skin":"light","width":"css","height":"css","navType":"none","scaleMode":"fit","imagePosition":"center","random":false,"loop":false,"videoAutoplay":false,"autoplayProgress":true,"pauseAutoplayOnHover":false,"keyboard":true,"captions":true,"controls":true,"combineNavItems":true,"gapSize":"0%"});$(function(){if (!$.fn.colorbox){return;}var lightboxConfig={loop: false,rel: function(){return $(this).attr('data-lightbox');},maxWidth: '95%',maxHeight: '95%'};var update=function(links){links.colorbox(lightboxConfig);};slider.on('rsts-slidestop',function(event){update(slider.find('a[data-lightbox]'));});update(slider.find('a[data-lightbox]'));});})(jQuery);
</script>
</div>
</div>
</header>
</body>
</html>
What you had was: show level 2 when you hover the main ul, what you wanted is: show level 2 when an li inside the main ul is hovered.

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-->