Navbar dropdown not displaying properly - html

I want the dropdown on my navbar to be wide enough the the text in it displays properly, but it's constrained to the size of the button you hover over to activate it. I want the dropdown to be a bigger width than the button.
The title displays fine in browser so not too sure why it is misaligned in the fiddle.
#center-title {
width: 200px;
font-size: 30px;
color: white;
position: fixed;
left: 50%;
transform: translateX(-50%);
text-align: center;
}
#cog {
width: 20px;
height: 20px;
margin-right: 50px;
margin-top: 15px;
}
#dropdown {
float: right;
position: relative;
display: inline-block;
}
#dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0#2);
}
#dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
#dropdown-content a:hover {
background-color: #f1f1f1
}
#dropdown:hover #dropdown-content {
display: block;
}
nav {
background-color: #2b569a;
width: 100%;
height: 50px;
margin-top: 0;
}
<nav>
<div class="center">
<h1 id="center-title"> Blocs </h1>
</div>
<div id="dropdown">
<img id="cog" src="/static/images/cog2.png" alt="" />
<div id="dropdown-content">
Profile
Settings
Logs
Email list
</div>
</div>
</nav>

Add right: 0; to #dropdown-content.
#center-title {
width: 200px;
font-size: 30px;
color: white;
position: fixed;
left: 50%;
transform: translateX(-50%);
text-align: center;
}
#cog {
width: 20px;
height: 20px;
margin-right: 50px;
margin-top: 15px;
}
#dropdown {
float: right;
position: relative;
display: inline-block;
}
#dropdown-content {
display: none;
position: absolute;
right: 0;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0#2);
}
#dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
#dropdown-content a:hover {
background-color: #f1f1f1
}
#dropdown:hover #dropdown-content {
display: block;
}
nav {
background-color: #2b569a;
width: 100%;
height: 50px;
margin-top: 0;
}
<nav>
<div class="center">
<h1 id="center-title"> Blocs </h1>
</div>
<div id="dropdown">
<img id="cog" src="/static/images/cog2.png" alt="" />
<div id="dropdown-content">
Profile
Settings
Logs
Email list
</div>
</div>
</nav>

You can use display:flex,instead of using float's and display:inline-block for layouts.
check this snippet
. #center-title {
width: 200px;
font-size: 30px;
color: white;
position: fixed;
left: 50%;
transform: translateX(-50%);
text-align: center;
}
#cog {
width: 20px;
height: 20px;
margin-right: 50px;
margin-top: 15px;
}
.center {
margin: auto;
}
#dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
right: 20px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0#2);
}
#dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
#dropdown-content a:hover {
background-color: #f1f1f1
}
#dropdown:hover #dropdown-content {
display: block;
}
nav {
background-color: #2b569a;
width: 100%;
height: 50px;
margin-top: 0;
display: flex;
justify-content: flex-end;
align-content: center;
}
<nav>
<div class="center">
<h1 id="center-title"> Blocs </h1>
</div>
<div id="dropdown">
<img id="cog" src="/static/images/cog2.png" alt="" />
<div id="dropdown-content">
Profile
Settings
Logs
Email list
</div>
</div>
</nav>
</div>
Hope it helps

Related

Responsive navbar with dropdown table and logo between divs

I`m trying to make this navbar responsive, and have not found a code that works in this example. When I adjust the width of the screen, I want all the links (not the logo) to be gathered in a hamburger icon, so in portrait mode it will only display the logo and the hamburger icon with the links.
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_responsive_navbar_dropdown This example is very close to what I would like, but the content in my navbar is centered with a logo in between the links, and I couldn`t make it work. Also I want the third element (the logo) to be displayed instead of the first link (when the width reaches a certain point). Any help would be greatly appreciated
nav{
display: flex;
width: 100%;
height: 17%;
background: black;
align-items: center;
justify-content: center;
font-family: Times New Roman;
font-size: 1.5vw;
position: fixed;
top: 0;
z-index: 1;
}
nav a{
text-decoration: none;
background-color: white;
color: black;
margin: 0 40px;
padding: 16px;
border: 3px solid #f9c534;
}
#logo{
width: 7vw;
height: auto;
background: rgba(0,0,0,0.3);
border-radius: 50%;
margin: 0 5vw;
}
.dropbtn {
padding: 16px;
background: white;
font-family: Times New Roman;
font-size: 1.5vw;
color: black;
border: 3px solid #f9c534;
margin: 0 40px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
margin: 0;
text-decoration: none;
display: block;
}
nav a:hover {
background-color: #f9c534;
border: 2px solid white;
}
.dropdown-content a:hover {
background-color: #f9c534;
border: 2px solid white;
}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {
background-color: #f9c534;
border: 2px solid white;
}
<nav>
Home
News
<div><img id="logo" src="src/Logo.jpg" alt=""></div>
Sponsors
<div class="dropdown">
<button class="dropbtn">About us</button>
<div class="dropdown-content">
Our employees
About company
Founder
</div>
</div>
</nav>
I just updated your code with few fixes your logo will always on center and hamburger menu also added. I hope it'll help you out. Thanks
nav {
background: black;
font-family: Times New Roman;
font-size: 14px;
height: 94px;
position: fixed;
width: 100%;
z-index: 1;
}
nav ul {
display: flex;
justify-content: space-around;
align-items: center;
list-style: none;
padding: 0;
margin: 0;
height: 94px;
}
nav ul li {
background-color: white;
border: 3px solid #f9c534;
position: relative;
white-space: nowrap;
}
nav ul li:hover {
background-color: #f9c534;
border-color: #fff;
}
nav ul li a {
color: black;
display: block;
margin: 0;
padding: 16px;
text-decoration: none;
}
nav li ul {
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
display: none;
position: absolute;
right: -3px;
top: 50px;
height: auto;
min-width: 150px;
}
nav ul li:hover ul {
display: block;
}
nav #logo {
border-radius: 50%;
background: rgba(0,0,0,0.3);
border: 0;
padding: 0;
width: 100px;
}
#mob-dropChecked {
display: none !important;
}
#media only screen and (max-width: 768px) {
nav {
height: 60px;
}
nav ul {
display: block;
height: 60px;
position: relative;
top: 44px;
}
nav ul li {
display: none;
}
nav #logo {
display: block;
position: absolute;
left: 34%;
top: -29px;
}
#mob-btn {
background-image: url('https://www.shareicon.net/data/512x512/2017/05/09/885755_list_512x512.png');
background-color: transparent;
border: 0;
background-repeat: no-repeat;
background-size: contain;
position: relative;
top: 21px;
height: 40px;
width: 40px;
padding: 13px 20px;
z-index: 2;
}
#mob-dropChecked:checked ~ ul li{
display: block;
}
nav li ul {
position: relative;
right: 0;
top: 16px;
}
}
<nav>
<label for="mob-dropChecked" id="mob-btn"></label>
<input type="checkbox" id="mob-dropChecked" role="button">
<ul>
<li>Home</li>
<li>News</li>
<li id="logo"><img id="logo" src="https://s.w.org/style/images/about/WordPress-logotype-alternative-white.png" alt=""></li>
<li>Sponsors</li>
<li>About us
<ul>
<li>Our employees</li>
<li>About company</li>
<li>Founder</li>
</ul>
</li>
</ul>
</nav>
You can add class to the wrapper div of logo img tag
and add css position: absolute; top: 10px; left: 10px to it for smaller devices using css media queries.
Else (not recommended), you can use two img tags. Hide one on desktop and another on mobile using display: block / display: none.
You could remove the logo from the nav and add a spacer element in its place. Then use absolute position on the logo to get it into place. It's a bit hacky, but would work. https://codepen.io/nickberens360/pen/bZmGWy
header{
position: fixed;
width: 100%;
top: 0;
}
.logo{
display: block;
margin: auto;
position: absolute;
left: 36px;
right: 0;
margin-left: auto;
margin-right: auto;
width: 200px;
z-index: 99999999;
top: 0;
}
.spacer{
margin: 0 100px;
border: 1px solid red;
}
nav{
display: flex;
width: 100%;
height: 17%;
background: black;
align-items: center;
justify-content: center;
font-family: Times New Roman;
font-size: 1.5vw;
z-index: 1;
}
nav a{
text-decoration: none;
background-color: white;
color: black;
margin: 0 40px;
padding: 16px;
border: 3px solid #f9c534;
width: 143px;
text-align: center;
}
#logo{
width: 7vw;
height: auto;
background: rgba(0,0,0,0.3);
border-radius: 50%;
margin: 0 5vw;
}
.dropbtn {
padding: 16px;
background: white;
font-family: Times New Roman;
font-size: 1.5vw;
color: black;
border: 3px solid #f9c534;
margin: 0 40px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
margin: 0;
text-decoration: none;
display: block;
}
nav a:hover {
background-color: #f9c534;
border: 2px solid white;
}
.dropdown-content a:hover {
background-color: #f9c534;
border: 2px solid white;
}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {
background-color: #f9c534;
border: 2px solid white;
}

A Section in My HTML is having a problem with its position

I have a site and it has 2 sections. the left section is a navigation bar with menus below.
The section next to it is the main section or where the website content must be placed. My problem is the right section is positioned a few pixels from the header. How can i fix this? I provided some image to let you see how the website should look like.
/*WRITTEN USING SASS*/
#side-menu{
margin-top: 25px;
.side-menu-bg {
width: max-content;
h3 {
position: absolute;
color: white;
padding: 0px 18px;
font-size: 27px;
}
img {
display: -webkit-box;
}
}
.side-nav-bar {
width: 210px;
position: unset;
margin-top: -3px;
display: inline-flex;
z-index: 1;
flex-direction: column;
overflow-x: hidden;
background-color: #ffffff;
a {
display: inherit;
color: #707070;
text-decoration: none;
font-size: 15px;
padding: 10px 18px;
position: relative;
border-bottom: 1px solid #e8e8e8;
}
.active-link{
color: #a40022;
border-bottom: 2px solid #8a001c;
}
}
.right-contents {
float: right;
.title h3 {
font-size: 38px;
}
.body-content {
background-color: #d3d3d3;
height: 1094px;
width: 738px;
}
}
}
<div class="wrapper"> <!--to make contents center-->
<div id="side-menu">
<div class="side-menu-bg">
<h3>KU 스타트업</h3>
<img src="images/bg/bg_03.png">
</div>
<div class="side-nav-bar">
인사말
창업 비전
창업 프로세스
창업부서소개
찾아오시는 길
</div>
<div class="right-contents">
<div class="title">
<h3>인사말</h3>
<div class="body-content">
sample text
</div>
</div>
</div>
</div>
</div>
Add margin: 0 to your h3 tag.. h3 has margin-to and margin-bottom by default. thanks
.right-contents {
float: right;
.title h3 {
font-size: 38px;
margin: 0; /*add this*/
}
.body-content {
background-color: #d3d3d3;
height: 1094px;
width: 738px;
}
<style>
/*WRITTEN USING SASS*/
#side-menu{
margin-top: 25px;
.side-menu-bg {
width: max-content;
h3 {
position: absolute;
color: white;
padding: 0px 18px;
font-size: 27px;
}
img {
display: -webkit-box;
}
}
.side-nav-bar {
width: 210px;
position: unset;
margin-top: -3px;
display: inline-flex;
z-index: 1;
flex-direction: column;
overflow-x: hidden;
background-color: #ffffff;
}
a {
display: inherit;
color: #707070;
text-decoration: none;
font-size: 15px;
padding: 10px 18px;
position: relative;
border-bottom: 1px solid #e8e8e8;
}
.active-link{
color: #a40022;
border-bottom: 2px solid #8a001c;
}
}
.right-contents {
width: 65%;
margin-top: -3px;
display: inline-flex;
.title h3 {
font-size: 38px;
}
.body-content {
background-color: #d3d3d3;
height: 1094px;
width: 738px;
}
</style>

Dropdown menu stuck behind div

My dropdown menu is stuck behind my main div or trapped within the header. I have messed with the z-index and that has not helped. How would I be able to tell if it was the header trapping it rather than the main div hiding it.
Here is a pic of the issue:
body {
margin: 0;
font-family: arial;
}
button {
border-style: solid;
border-color: black;
border-radius: 5px;
}
a {
text-decoration: none;
color: blue;
}
#header {
overflow: hidden;
background-color: #FFF;
position: fixed;
top: 0;
width: 100%;
height: 50px;
border-bottom: solid;
border-bottom-color: black;
}
.headerSection {
float: left;
width: 33%;
height: 100%;
display: table;
text-align: center;
}
.headerSection>.headerItem {
display: table-cell;
vertical-align: middle;
}
#asdf {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
border-radius: 0;
background: #1466C0;
color: #FFAD01;
border-bottom: 0;
}
#asdf:hover {
background-color: #00B2EE;
}
.TOC {
margin-top: 25px;
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 999;
}
.dropdown:hover .TOC {
display: block;
}
.TOC a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
#main {
margin-top: 55px;
z-index: 1;
}
<div id="header">
<div class="headerSection">
<div class="dropdown">
<button class="headerItem" id="asdf">&#9776</button>
<div class='TOC'>
<a href='#OS'>OS Information</a>
<a href='#GI'>General Information</a>
<a href='#DI'>Domain Information</a>
<a href='#SUC'>Start-Up Command</a>
<a href='#shares'>Shares</a>
<a href='#EV'>Environment Vars</a>
<a href='#proc'>Processes</a>
</div>
</div>
</div>
<div class="headerSection">
<h1 class="headerItem">Windows Audit Script Report</h1>
</div>
<div class="headerSection">
<p class="headerItem" id="aede">Run Time: 2018-06-28 10:11:24.145067</p>
</div>
</div>
<div id="main">
<div style='clear:both'></div>
Does anyone have any ideas on how to fix this issue?
It happens because your header has overflow:hidden you should remove overflow hidden
please check the changes :
body
{
margin: 0;
font-family: arial;
}
button
{
border-style: solid;
border-color: black;
border-radius: 5px;
}
a
{
text-decoration: none;
color: blue;
}
#header
{
background-color: #FFF;
position: fixed;
top: 0;
width: 100%;
height: 50px;
border-bottom: solid;
border-bottom-color: black;
}
.headerSection
{
float: left;
width: 33%;
height: 100%;
display: table;
text-align: center;
}
.hidden-height-header{width:66%; float:left; height:50px; overflow:hidden}
.hidden-height-header >.headerSection {width:50%}
.headerSection > .headerItem
{
display: table-cell;
vertical-align: middle;
}
#asdf
{
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
border-radius: 0;
background: #1466C0;
color: #FFAD01;
border-bottom: 0;
}
#asdf:hover
{
background-color: #00B2EE;
}
.TOC {
margin-top: 25px;
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 999;
}
.dropdown:hover .TOC {
display: block;
}
.TOC a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
#main
{
margin-top: 55px;
z-index: 1;
}
<body>
<div id="header">
<div class="headerSection">
<div class="dropdown">
<button class="headerItem" id="asdf">&#9776</button>
<div class='TOC'>
<a href='#OS'>OS Information</a>
<a href='#GI'>General Information</a>
<a href='#DI'>Domain Information</a>
<a href='#SUC'>Start-Up Command</a>
<a href='#shares'>Shares</a>
<a href='#EV'>Environment Vars</a>
<a href='#proc'>Processes</a>
</div>
</div>
</div>
<div class="hidden-height-header">
<div class="headerSection">
<h1 class="headerItem">Windows Audit Script Report</h1>
</div>
<div class="headerSection">
<p class="headerItem" id="aede">Run Time: 2018-06-28 10:11:24.145067</p>
</div>
</div>
</div>
<div id="main">
<div style = 'clear:both'></div>
</div></body>
The issue is the overflow: hidden that you have set on the #header. If you remove that the dropdown should work fine.
jsfiddle: https://jsfiddle.net/1du6f928/1/

web page layout problems

I am working on web page layouts. I created this one.
https://codepen.io/iamgonge/pen/paOxxb
I dont understand why the .container .left-side and .right-side elements start at the top of the browser and not below the header. Shouldn't the layout out be header->section(hero)->section(one)? I would think that the top of any of those three divs would be underneath the header but they are not. What amy I not understanding here?
body {
font-family: Verdana, Geneva, sans-serif;
margin: 0;
padding: 0;
}
.container {
background: #333338;
display: inline-block;
width: 60%;
height: 800px;
}
header {
position: fixed;
background: #10105f;
width: 100%;
height: 150px;
}
.main-links a {
text-decoration: none;
color: #fff;
font-size: 20px;
text-transform: uppercase;
}
.main-links a:hover {
color: #00843d;
}
.main-links a:active {
color: red;
}
.left-side {
display: inline-block;
width: 20%;
background: #4C4C59;
height: 800px;
float: left;
}
nav {
position: absolute;
bottom: 0;
left: 0;
height: 50px;
width: 100%;
text-align: center;
}
nav ul {
margin: auto;
padding: 0;
display: inline-block;
list-style: none;
color: #fff;
// border: 1px solid #00843D;
width: 60%;
;
}
nav li {
display: inline-block;
margin: 5px -3px;
padding: 5px 10px;
// border: 1px solid#fff;
}
nav li:hover {
background: rgba(255, 255, 255, 0.25);
}
nav li:active {
border-bottom: 2px solid red;
color: red;
}
.nav-left {
float: left;
height: 50px;
width: 20%;
padding-bottom: 96px;
// border: 1px solid #00843D;
}
.nav-right {
float: right;
height: 50px;
width: 20%;
padding-bottom: 96px;
//border: 1px solid #00843D;
}
.nav-center {
position: relative;
padding-bottom: 21px;
margin: 0 auto;
height: 75px;
width: 300px;
// border: 1px solid #00843D;
}
.nav-right p a {
font-size: 16px;
text-decoration: none;
color: #fff;
}
.nav-right p a:hover {
color: #00843d;
}
.nav-right p {
margin: 20px;
padding: 0;
color: #fff;
}
.one {
display: block;
width: 100%;
height: 800px;
background: #080853;
}
.right-side {
display: inline-block;
width: 20%;
background: #4C4C59;
height: 800px;
float: right;
}
.rss-title,
.rss-date {
margin: 0px!important;
}
.rss-feed {
margin: 10px 5px 20px 0px;
}
.rss-date {
padding: 0;
font-size: 12px;
font-style: italic;
}
.hero,
.one {
position: relative;
height: 100%;
}
.success {
display: block;
text-align: center;
margin-top: 20%;
font-size: 69px;
color: #00843d;
// margin-left: auto;
// margin-right: auto;
}
.success:hover {
font-size: 71px;
}
#timestamp {
margin: 10px 5px 20px 0px;
text-align: center;
color: #fff;
font-size: 16px;
}
#timestamp,
.rss-feed {
background: #080853;
padding: 10px;
height: 110px;
}
#media (min-width:1530px) {}
<body>
<header>
<div class="nav-left">
<div id="timestamp"></div>
</div>
<div class="nav-right"></div>
<div class="nav-center"></div>
<nav>
<ul class="main-nav">
<li class="main-links">home</li>
<li class="main-links">about</li>
<li class="main-links">projects</li>
<li class="main-links">portal</li>
<li class="main-links">links</li>
</ul>
</nav>
</header>
<section="hero">
<div class="left-side"></div>
<div class="right-side"></div>
<div class="container">
<div class="success"></div>
</div>
<!--***Container***-->
</section>
<section class="one"></section>
</body>
The reason is that you have applied position: fixed; to your <header> tag. When you do this you must account for the height of the header and push down other elements to restore the layout.

Weird dropdown behavior css

I have two dropdown lists and they work as expected(that they show the content on hover) however, If I click on the area outside (left side) the list , the dropdown list still shows.
I have tried fixing the CSS but I have not been able to pin point the problem.
Is there a better approach for styling dropdown as I am still new to CSS.
UPDATE:
Testing this in firefox and I was unable to recreate the issue. How can I make sure that works consistently in all browsers?
.dropbtn {
color: white;
width: 200px;
margin-top: 160px;
margin-left: 276px;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
text-align: left;
font-weight: 900;
background: rgba(0, 173, 239, 1);
border-radius: 0px;
-moz-border-radius: 0px;
-webkit-border-radius: 50px 50px 50px 50px;
position: relative;
z-index: 2;
}
.dropdown {
position: relative;
display: inline-block;
width: 480px;
height: 0px;
background: antiquewhite;
}
.dropdown-content {
display: none;
position: relative;
z-index: 1;
background-color: #f9f9f9;
/* min-width: 160px; */
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
right: 5px;
top: -20px;
margin-left: 283px;
}
.sphere {
height: 45px;
width: 45px;
border-radius: 50%;
vertical-align: top;
/* position: relative; */
background: black;
display: inline-block;
position: relative;
margin-top: 165px;
margin-left: -55px;
z-index: 2;
}
.dropdown-content a {
table-layout: fixed;
color: black;
margin-left: -1px;
padding: 12px 16px 13px 30px;
text-decoration: none;
display: block;
border: 1px solid #000;
border-top: none;
font-size: 21px;
}
.dropdown-content a:first-child {
padding-top: 35px;
background: url("Images/sidearrow.png") no-repeat 7px 36px;
}
.dropdown a {
background:url("Images/sidearrow.png") no-repeat 7px;
}
.dropdown-content a:first-child:hover {
padding-top: 35px;
background: url("Images/sidewhite.png") no-repeat 3px 36px;
color:black;
background-color: rgb(255,131,0);
}
.dropdown-content a:hover {
background:url("Images/sidewhite.png") no-repeat 3px;
background-color: rgb(255,131,0);
color:white;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
div#arrow {
position: absolute;
margin-left: 10px;
margin-top: 11px;
}
/* SENTINAL */
.dropbtn-sentinal {
color: white;
width: 200px;
margin-top: 160px;
margin-left: 276px;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
text-align: left;
font-weight: 900;
background: rgba(0, 173, 239, 1);
border-radius: 0px;
-moz-border-radius: 0px;
-webkit-border-radius: 50px 50px 50px 50px;
position: relative;
z-index: 2;
}
.dropdown-sentinal{
position: relative;
display: inline-block;
width: 480px;
height: 0px;
background: antiquewhite;
}
.dropdown-content-sentinal {
display: none;
position: relative;
z-index: 1;
background-color: #f9f9f9;
/* min-width: 160px; */
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
right: 5px;
top: -20px;
margin-left: 283px;
}
.sphere-sentinal {
height: 45px;
width: 45px;
border-radius: 50%;
vertical-align: top;
/* position: relative; */
background: black;
display: inline-block;
position: relative;
margin-top: 165px;
margin-left: -55px;
z-index: 2;
}
.dropdown-content-sentinal a {
table-layout: fixed;
color: black;
margin-left: -1px;
padding: 12px 16px 13px 30px;
text-decoration: none;
display: block;
border: 1px solid #000;
border-top: none;
font-size: 21px;
}
.dropdown-content-sentinal a:first-child {
padding-top: 35px;
background: url("Images/sidearrow.png") no-repeat 7px 36px;
}
.dropdown-sentinal a {
background:url("Images/sidearrow.png") no-repeat 7px;
}
.dropdown-content-sentinal a:first-child:hover {
padding-top: 35px;
background: url("Images/sidewhite.png") no-repeat 3px 36px;
color:black;
background-color: rgb(255,131,0);
}
.dropdown-content-sentinal a:hover {
background:url("Images/sidewhite.png") no-repeat 3px;
background-color: rgb(255,131,0);
color:white;
}
.dropdown-sentinal:hover .dropdown-content-sentinal {
display: block;
}
.dropdown-sentinal:hover .dropbtn-sentinal {
background-color: #3e8e41;
}
div#arrow-sentinal {
position: absolute;
margin-left: 10px;
margin-top: 11px;
}
div#dropdown-one {
width: 500px;
height: 198px;
}
div#dropdown-two {
margin-left: 700px;
margin-top: -198px;
}
div#dropdown-content a {
text-decoration: none;
border: solid black 1px;
display: table-caption;
background-color: rgb(237,237,238);
background: url(Images/sidearrow.png) no-repeat 7px 36px;
}
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<link rel="stylesheet" type="text/css" href="dropdown.css">
<meta charset="utf-8">
</head>
<body>
<div class="averios-header">
<div id="averios-logo">
<img src="averioslogo.png" width="176" height="129">
</div>
<div id="setting-dropdown">
<!-- SETTING DROPDOWN WILL GO HERE -->
</div>
<div id="header-hr">
</div>
</div>
<div id="log-in">
<div id="loginHeader">
<h1>Portal</h1>
</div>
<div id="welcome-text">
<p> Welcome name </p>
<p> Your last login was time on date </p>
<br>
<p> Please select an application below to begin </p>
</div>
</div>
<div id="dropdown-one">
<div class="dropdown">
<button class="dropbtn">SELECT</button>
<div class="sphere">
<div id="arrow">
<img src="C:\Users\mseh\Desktop\Images\arrow.png" width="29" height="27" alt=""/>
</div>
</div>
<div class="dropdown-content">
Link 1
Link 1
Link 1
Link 1
</div>
</div>
</div>
<div id="dropdown-two">
<div class="dropdown-sentinal">
<button class="dropbtn-sentinal">SELECT</button>
<div class="sphere-sentinal">
<div id="arrow-sentinal">
<img src="C:\Users\mseh\Desktop\Images\arrow.png" width="29" height="27" alt=""/>
</div>
</div>
<div class="dropdown-content-sentinal">
Link 1
Link 1
Link 1
Link 1
</div>
</div>
</div>
</body>
</html>
Here - I shortened the example down a bit (I also don't think you need all that separate CSS for more than one button, you should be able to utilize the classes, and just change specifics by using #dropdown_two .classname for the things (like position) you might want to change.
The problem in Chrome, I think, was that the width of the container was wider than the button itself, and that made it misbehave. It might not be 100%, but it should get you started. I changed some values to dynamic (em instead of px) so there might be some issues.
#dropdown-one {
margin-left: 20em;
}
.dropbtn {
color: white;
width: 100%;
height: 3.2em;
font-size: 16px;
border: none;
cursor: pointer;
text-align: left;
font-weight: 900;
background: rgba(0, 173, 239, 1);
border-radius: 0px;
-moz-border-radius: 0px;
-webkit-border-radius: 50px 50px 50px 50px;
position: relative;
z-index: 2;
}
.dropdown {
position: relative;
display: block;
width: 12.5em;
background:antiquewhite;
}
.dropdown-content {
display: none;
position: relative;
z-index: 1;
background-color: #f9f9f9;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
top: -20px;
}
.sphere {
height: 2.9em;
width: 2.9em;
border-radius: 50%;
border: 2px solid rgba(0, 173, 239, 1);
/* position: relative; */
background: black;
position: absolute;
top: 0;
bottom: 0;
right: .1em;
z-index: 2;
}
.dropdown-content a {
table-layout: fixed;
color: black;
padding: .75em;
text-decoration: none;
display: block;
border: 1px solid #000;
border-top: none;
font-size: 21px;
box-sizing: border-box;
}
.dropdown-content a:first-child {
padding-top: 35px;
background: url("Images/sidearrow.png") no-repeat 7px 36px;
}
.dropdown a {
background:url("Images/sidearrow.png") no-repeat 7px;
}
.dropdown-content a:first-child:hover {
background: url("Images/sidewhite.png") no-repeat 3px 36px;
color:black;
background-color: rgb(255,131,0);
}
.dropdown-content a:hover {
background:url("Images/sidewhite.png") no-repeat 3px;
background-color: rgb(255,131,0);
color:white;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
div#arrow {
position: absolute;
margin-left: 10px;
margin-top: 11px;
}
<div class="averios-header">
<div id="setting-dropdown">
<!-- SETTING DROPDOWN WILL GO HERE -->
</div>
</div>
<div id="log-in">
<div id="loginHeader">
<h1>Portal</h1>
</div>
<div id="welcome-text">
<p> Welcome name </p>
<p> Your last login was time on date </p>
<p> Please select an application below to begin </p>
</div>
</div>
<div id="dropdown-one">
<div class="dropdown">
<button class="dropbtn">SELECT</button>
<div class="sphere">
<div id="arrow">
<img src="C:\Users\mseh\Desktop\Images\arrow.png" width="29" height="27" alt=""/>
</div>
</div>
<div class="dropdown-content">
Link 1
Link 1
Link 1
Link 1
</div>
</div>
</div>