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-->
Related
i have a container div where i have my logo, and at the right i have my menu, what i want to do is, when the navbar gets at screen size mobile i want each to be on a row and each row is the size of a container-fluid, at the moment the issue is that each li size is the same of my container, how i can change this?
this is my code:
<div id="navigation_bar">
<div class="content">
<div id="logo">
<a href="index.html">
<img class="logo_dark" src="images/virtuai/logo-dark.png" alt="Enar Logo">
<img class="logo_light" src="images/logo-light.png" alt="Enar Logo">
</a>
</div>
<nav id="main_nav navbar-right">
<div id="nav_menu">
<span class="mobile_menu_trigger">
<span></span>
</span>
<ul id="navy" class="clearfix" style="float:right">
<li class="normal_menu mobile_menu_toggle current_page_item">
<span>HOME</span>
</li>
<li class="normal_menu mobile_menu_toggle current_page_item">
<span>ABOUT US</span>
</li>
<li class="normal_menu mobile_menu_toggle current_page_item">
<span>SOLUTIONS</span>
</li>
<li class="normal_menu mobile_menu_toggle current_page_item">
<span>CONTACT US</span>
</li>
</ul>
</div>
</nav>
<!-- End Nav -->
<div class="clear"></div>
</div>
Try this code..
overwrite the bootstrap container width
#media screen and (max-width: 768px) {
body .container{
width:100% !important;
}
}
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>
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{}
I want to align the tab list to center. As you can see in the image below it is shifted to the left. Bootstrap class center-block is already included but still it doesn't work. Please Help me!!!
Here's my HTML of my code:-
<ul class="nav nav-tabs center-block" role="tablist">
<!-- Schedule -->
<li role="presentation" class="active">
<a href="#" aria-controls="dem" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<span>Schedule</span>
</a>
</li>
<!-- Resource -->
<li role="presentation">
<a href="#" aria-controls="resource" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<span>Resource</span>
</a>
</li>
<!-- Automation -->
<li role="presentation">
<a href="#" aria-controls="automation" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<span>Automation</span>
</a>
</li>
<!-- Customize -->
<li role="presentation">
<a href="#" aria-controls="customize" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<span>Customize</span>
</a>
</li>
</ul>
ANd here's my CSS-
.ilpFeatureSection .nav-tabs {
border-bottom: none
}
#media(min-width:480px) {
.ilpFeatureSection .nav-tabs {
width: 390px
}
}
#media(min-width:768px) {
.ilpFeatureSection .nav-tabs {
width: 600px
}
}
#media(min-width:992px) {
.ilpFeatureSection .nav-tabs {
width: 800px
}
}
#media(min-width:1200px) {
.ilpFeatureSection .nav-tabs {
width: 1000px
}
}
Thanks :)
Use nav-justified and remove center-block from your nav.
nav-justified is a prewritten bootstrap class to center your nav. It simply does what #SankarRaj wanted too with .nav-tabs{width:100%}
I believe this is because Bootstrap uses "float: left" on the nav-tabs items. You would need to set "float: none" and "display: inline-block" on the list items
Try this
CSS
.ilpFeatureSection .nav-tabs {
border-bottom: none
margin: auto;
}
Add container and make nav-justified. Then try it in full page
.ilpFeatureSection .nav-tabs {
border-bottom: none
}
#media(min-width:320px) {
.nav-tabs.nav-justified>li{
width:25% !important;
float:left !important;
}
}
#media(min-width:480px) {
.nav-tabs.nav-justified>li{
width:25% !important;
float:left !important;
}
}
#media(min-width:768px) {
.nav-tabs.nav-justified>li {
width:1% !important;
float:none !important;
}
}
#media(min-width:992px) {
.nav-tabs.nav-justified>li {
width:1% !important;
float:none !important;
}
}
#media(min-width:1200px) {
.nav-tabs.nav-justified>li {
width:1% !important;
float:none !important;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<ul class="nav nav-tabs nav-justified" role="tablist">
<!-- Schedule -->
<li role="presentation" class="active">
<a href="#" aria-controls="dem" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<br/>
<span>Schedule</span>
<br/>
</a>
</li>
<!-- Resource -->
<li role="presentation">
<a href="#" aria-controls="resource" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<br/> <span>Resource</span>
</a>
</li>
<!-- Automation -->
<li role="presentation">
<a href="#" aria-controls="automation" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<br/> <span>Automation</span>
</a>
</li>
<!-- Customize -->
<li role="presentation">
<a href="#" aria-controls="customize" role="tab" data-toggle="tab">
<img alt="icon" src="#" class="iconDark">
<img alt="icon" src="#" class="iconWhite">
<br/><span>Customize</span>
</a>
</li>
</ul>
</div>
</body>
</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>