I have a dropdown menu that is activated with a button within my navbar. When the dropdown menu button is activated then 95% of the menu disappears when the mouse hovers over the navbar and other buttons. Furthermore, I cannot select any of the dropdown menu items without the menu flickering. I'm looking to have the menu work as illustrated in the image below without the navbar being out of whack. Any help is appreciated :)
I think it may be a div sizing issue. I have played around with the .card CSS and noticed that if the height of the Navbar, and the card it sits on, is greater than the height of the menu then the menu becomes fully functional without the issues above. I have also played around with z-index to make sure the component stays in front but the result is the same. I have attached a few files to illustrate the issue/troubleshooting.
Navbar component CSS:
div.navbar-div{
display: inline;
top: 0;
justify-content: center;
background-color: #FFFFFF;
color: #FFFFFF;
}
.logo-img{
display: flex;
height: 30%;
}
.navbar-card{
z-index: 990;
display: flex;
width: fit-content;
border-radius: 50px;
top: 0;
position: sticky;
margin: 10px 20px;
transform:scale(1, 1);
transition: 0.0s;
&:hover{
overflow: hidden;
transform: scale(1.00);
}
}
.sticky-top{
display: flex;
width: max-content;
border-radius: 50px;
margin: 10px 0px 10px 0px;
}
.navbar-collapse{
width: max-content;
}
.nav-item{
position: relative;
padding: 0px 4px;
}
.navbar-nav{
display: flex;
position: fix;
justify-content: center;
}
.btn-pill{
padding: 5px 15px 5px 15px;
color: #FFFFFF;
font-size: medium;
margin: 0% 0.5% 0% 0.5%;
}
.button-icon{
margin: 0px 10px 0px 0px;
}
.shopping-cart > .button-icon{
margin: 0px 0px 0px 0px;
}
.btn{
width: 100%;
height: 40px;
white-space: nowrap;
}
.search-box-container{
width: 50px;
height: 40px;
}
Dropdown Menu component:
function NavDropdownMenu () {
function DropDownItem(props){
return(
<a href="#" className="menu-item">
<span className="icon-button">{props.leftIcon}</span>
{props.children}
<span className="icon-right">{props.rightIcon}</span>
</a>
);
}
return(
<div className="dropdown">
{/* <DropDownItem>Test</DropDownItem> */}
<DropDownItem
leftIcon={<RiKnifeLine/>}
rightIcon={<FaRegArrowAltCircleRight/>}>
</DropDownItem>
<DropDownItem
leftIcon={<RiKnifeLine/>}
rightIcon={<FaRegArrowAltCircleRight/>}>
</DropDownItem>
<DropDownItem
leftIcon={<RiKnifeLine/>}
rightIcon={<FaRegArrowAltCircleRight/>}>
</DropDownItem>
<DropDownItem
leftIcon={<RiKnifeLine/>}
rightIcon={<FaRegArrowAltCircleRight/>}>
</DropDownItem>
</div>
);
Dropdown Component CSS:
.dropdown{
position: absolute;
top: 58px;
right: 22%;
width: 300px;
transform: translate(-45%);
background-color: #ddd;
// border: ;
border-radius: 15px;
padding: 1rem;
overflow: hidden;
z-index: 999;
}
.menu-item{
height: 55px;
display: flex;
align-items: center;
border-radius: 10px;
transition: background(500ms);
padding: 0.5rem;
// position: absolute;
}
.menu-item:hover{
background-color: #fff;
}
.icon-right{
margin-left: auto;
}
Cheers
removed several attributes and until I figured out my navbar had overflow: hidden. Changed to visible and it now displays the dropdown without flickering.
Related
I am using the following CSS to display a progresbar and in it I display the time that is left. For some reason no matter what I try the displayed time wont stay at its place and is moving left as the proress bar width is decreasing. I have tried a lot of ways to keep the text from moving and keep it centered but none seems to work. Please help !
CSS:
.progress {
background: rgba(255,255,255,0.1);
justify-content: flex-start;
border-radius: 100px;
align-items: center;
position: relative;
padding: 0 5px;
display: flex;
height: 20px;
width: 300px;
}
.progress-value {
box-shadow: 0 10px 40px -10px #fff;
border-radius: 100px;
background: red;
height: 15px;
}
The div ( the div with the ID timer needs to be in the middle of the progres bar and it should not move while the progres bar is degreasing !)
<div class="progress">
<div id='progress' class="progress-value"><span id='timer' style="display: inline; width: 300px !important;"></span></div></center></div></center>
I solved this by wrapping the progress bar and the time element in another div, position relative, then I can absolutely position the time element in any position; in this case I centered it in the div.
The time stays put because it's out of the flow of the document but it's div takes up the same space as the progress bar.
.progress {
background: rgba(5,5,5,0.5);
justify-content: flex-start;
border-radius: 100px;
align-items: center;
padding: 0 5px;
display: flex;
height: 20px;
width: 100%;
}
.progress-value {
box-shadow: 0 10px 40px -10px #fff;
border-radius: 100px;
background: red;
height: 15px;
width: 35%;
}
.progress-and-timer {
position: relative;
}
.timer-value {
position: absolute;
text-align: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 20px;
color: white;
font-family: Arial, sans-serif;
font-size: 14px;
line-height: 20px;
}
<div class="progress-and-timer">
<div id="timer" class="timer-value">time</div>
<div class="progress">
<div id="progress" class="progress-value">
</div>
</div>
</div>
We are trying to create a chatbot application. The input where user enters the text and 'send' button are inside a div. The div width is 100%. This is working good in the laptop and on all the mobiles except Iphone14 where the send button is getting cutoff. Below is the code.
.chat-container {
background: #fff;
height: 100%;
overflow: hidden;
padding: 0;
border-right: 1px solid #d8dada;
border-left: 1px solid #d8dada;
}
.chat-container>div:last-of-type {
position: absolute;
bottom: 0;
width: 100%;
display: flex;
align-items: center;
padding-right: 10px;
}
body>div>div>div:nth-child(2)>span {
background: #dadada;
padding: 10px;
font-size: 21px;
border-radius: 50%;
}
body>div>div>div.message-data-right.macro {
margin: auto;
margin-left: 1%;
}
.chat-header {
background-color: #ffffff;
height: 3.5rem;
line-height: 3.5rem;
color: #000000;
border-bottom: 1px solid #000000;
position: relative;
}
.chat-header-content {
align-content: center;
padding-top: 10px;
padding-bottom: 10px;
}
.header-img {
height: 24px;
width: 106px;
transform: scale(0.85);
vertical-align: middle;
content: url('./../images/vz_logo.svg');
}
.gray-button {
background-color: #5b5b5b;
border: none;
color: white;
padding: 10px 24px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
font-family: Roboto-Medium;
border-radius: 4px;
}
.chat-ul {
width: 100%;
list-style-type: none;
padding: 18px 18px 3px 18px;
position: absolute;
bottom: 62px;
display: flex;
flex-direction: column;
top: 3.5rem;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: #909296 #dee0e2;
background-color: #f6f6f6;
margin-bottom: 0%;
border-bottom: 1px solid #c1c1c1;
}
.entered-text {
border-width: 1px;
border-radius: 5px;
padding: 10px;
background: #f6f6f6;
width: 100%;
border-color: #c1c1c1;
}
.text {
width: 100%;
display: flex;
flex-direction: column;
}
.text>p:first-of-type {
width: 100%;
margin-top: 0;
margin-bottom: auto;
line-height: 13px;
font-size: 13px;
}
.text>p {
width: 100%;
margin-top: 0;
margin-bottom: auto;
line-height: 13px;
font-size: 13px;
}
.text>p:last-of-type {
width: 100%;
text-align: right;
margin-bottom: -2px;
margin-top: auto;
}
.text-right {
float: right;
font-family: Arial;
position: relative;
}
.send-message {
width: 100%;
border-radius: 0px;
padding: 10px;
display: flex;
}
input:focus {
outline: none;
}
button,
button:focus,
button:active {
outline: none;
}
<div class="chat-container">
<header class="chat-header">
<img class="header-img" />
<button type="button" class="icon-close" onClick="closeChatWindow()"></button>
</header>
<ul class="chat-ul"></ul>
<div>
<div class="send-message">
<div class="text text-right">
<input class="entered-text" />
</div>
</div>
<button id="send" class="gray-button" type="button" onClick="onMessageSend()"> Send </button>
</div>
</div>
Our testing team raised a bug saying that send button gets cutoff on IPhone14. I am not sure how to reproduce the issue as I don't have Iphone14. I have Android phone on which code is working fine. On Pc also, I tested on different browsers all are working fine. I used toggle device toolbar under developer tools to check how it looks like for different devices and used responsive to change width and height. I am not able to reproduce the issue. Below is the image where it got reproduced on Iphone14.
At the end of the image 'Send' grey color button is cutoff. Can any one please let me know how to resolve the issue.
You don't need an iPhone to see this. It's apparent in Chrome for me. Use the emulator in the dev tools if you like.
Remove the float (.text-right) from the layout
Take the 100% width off the input and .send-message
Move the flex class up a level to contain both the input and the button
I've also added some left margin to the button.
I've fixed a great many such situations in my career, and more often than not the solution involves removing unnecessary styling to simplify. You might work though your entire layout and do so.
.gray-button {
background-color: #5b5b5b;
border: none;
color: white;
padding: 10px 24px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 15px;
font-family: Roboto-Medium;
border-radius: 4px;
margin-left: 10px;
}
.entered-text {
border-width: 1px;
border-radius: 5px;
padding: 10px;
background: #f6f6f6;
border-color: #c1c1c1;
}
.text {
width: 100%;
display: flex;
flex-direction: column;
}
.send-message {
border-radius: 0px;
padding: 10px;
display: flex;
}
input:focus {
outline: none;
}
button,
button:focus,
button:active {
outline: none;
}
<div class="chat-container">
<div class="send-message">
<div class="text">
<input class="entered-text" />
</div>
<button id="send" class="gray-button" type="button" onClick="onMessageSend()"> Send </button>
</div>
</div>
The most straightforward way to solve this is to is use the CSS calc() function to give input.entered-text a flexible width which will always accommodate the width of the <button>:
e.g. If you give button#send a fixed width (width: 100px), then you can give input.entered-text a width that can accommodate that fixed width (width: calc(100% - 100px))
Example:
#send {
display: inline-block;
width: 100px;
margin-left: 12px;
box-sizing: border-box;
}
.entered-text {
display: inline-block;
width: calc(100% - 12px - 100px);
box-sizing: border-box;
}
Im no expert but should you put a <br> in the div
edit:
line breaks are usually unnecessary so I would say only use this temporary until you find the solution
I have a modal window which has an absolutely positioned black div that covers the entire viewport whenever the modal window is open. For some reason though this window doesn't cover a certain element even though it goes over it. Everything else is covered by the black screen just fine so I have no idea why this specific element doesn't.
.black-screen {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
}
The element that is not being covered:
<div class="form-container">
<form class='send-message'>
<input class='message-input' placeholder="Type a message">
</form>
</div>
And the CSS of that element:
.form-container {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.send-message {
position: relative;
padding: 20px 0px 20px 20px;
flex: 1;
}
.message-input {
width: 100%;
padding: 15px;
outline: none;
border: none;
background-color: #40444b;
color: #dcddde;
font-size: 14px;
border-radius: 5px 0 0 5px;
}
With small chunk of css I can only guess (css is a cascade and is hereditary)
.form-container {
position: relative; /* remove this */
display: flex;
justify-content: center;
align-items: center;
}
.send-message {
position: relative; /* remove this */
padding: 20px 0px 20px 20px;
flex: 1;
}
.message-input {
width: 100%;
padding: 15px;
outline: none;
border: none;
background-color: #40444b;
color: #dcddde;
font-size: 14px;
border-radius: 5px 0 0 5px;
}
If for whatever reasons this is not possible or it doesn't work - replace div elements but I don't know if this will work in every browser ...
<div class="form-container">
<form class='send-message'> <input class='message-input' placeholder="Type a message"> </form>
</div>
<div class="black-screen">black</div>
If the problem persists, use Validator w3c to find out how bad it is
... in fact, use Validator no matter what
I'm using this grid as a top navabar and I want to make a few alterations:
How can I reduce the width of the input to 40% but still keep it right next to the logo? And how can I add a sign-in div at the right hand corner. But keep in mind that I want the entire header to remain responsive like it is now. If I do the following it looks good in a full screen but when the width of the screen is smaller the input becomes really small.
.top_nav_menu {
border-bottom: 1px solid #e3e3e3;
box-shadow: 0 0 8px 0 #eeeeee;
position: fixed;
top: 0px;
width: 100%;
height: auto;
background-color: #fafafa;
margin-right: 90px;
padding: 15px;
z-index: 2;
}
.header {
display: flex;
justify-content: flex-start;
align-items: center;
height: 50px;
}
.header > form {
width: 65%;
margin-left: 25px;
}
.header > form > input {
width: 40%;
}
<div class="top_nav_menu">
<div class="header">
<img src="http://i.imgur.com/EFkps0m.png">
<form><input type="text"></form>
<div class="floar-right">Sign-in</div
</div>
</div>
You can either reduce the value of 40% in your CSS.
Or add new CSS for max-width:
.header > form > input {
max-width: 50px;
}
For your sign-in div, you can add this CSS:
.float-right {
float:right;
}
However your current class spells floar and not float, you should change that.
you can use this code
body {
margin: 0;
padding: 0;
}
.top_nav_menu {
border-bottom: 1px solid #e3e3e3;
box-shadow: 0 0 8px 0 #eeeeee;
position: fixed;
top: 0px;
width: 100%;
height: auto;
background-color: #fafafa;
margin-right: 90px;
padding: 15px;
z-index: 2;
}
.header {
display: flex;
justify-content: flex-start;
align-items: center;
height: 50px;
}
.header > form {
width: 65%;
margin-left: 25px;
}
.header > form > input {
width: 24%;
}
<div class="top_nav_menu">
<div class="header">
<img src="http://i.imgur.com/EFkps0m.png">
<form><input type="text"></form>
<div class="floar-right">Sign-in</div>
</div>
</div>
As part of my HTML5/CSS3 app, I need to implement zoomable image popup. When the user clicks on a small image, a full-screen popup appears containing that image in the middle with a title above it and a button to close the popup below it. Clicking on the image then removes any scaling and puts it full-size inside a box in the middle to allow scrolling - with title and "close" button staying above and below.
I'm using flex (for several reasons, including vertical centering content). The overall popup works and looks fine. Clicking on the image does increase it in size, but it resizes the box so that the "done" button is pushed below the overall popup.
Here's the jsfiddle demonstrating the issue
I don't mind the fact that the box resizes - the more room to view/scroll the larger image - but I need to ensure that the button at the bottom stays put relative to the bottom edge of the popup.
My HTML looks like this (I used a random image for demonstration):
<div id="overlay" class="hidden">
<div id="alsg">
<div class="intro">Assist with ALS</div>
<div class="box scrollable">
<img src="http://upload.wikimedia.org/wikipedia/commons/8/8c/Male_monarch_butterfly.JPG" class="fit" />
</div>
<div class="popup-buttons">
<div id="button-alsg-done" class="button button-state-action button-green right">Done</div>
<div class="clear"></div>
</div>
</div> <!-- alsg -->
</div>
With the javascript being
$('img', '#alsg').on('click', function(e) {
$(this).toggleClass('fit');
});
There's a lot of CSS, unfortunately. You'll note that there's a pretty bad mix of flex and old-school positioning. This is because the app initially didn't use flex at all and I'm in a slow process of migrating/cleaning up now.
div#overlay {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 104;
display: flex;
align-items: center;
justify-content: center;
}
div#overlay > div {
position: relative;
width: calc(100% - 40px);
margin: 10px auto;
background-color: #A9A9A9;
border-radius: 8px;
text-align: center;
padding: 10px;
display: flex;
flex-direction: column;
}
div#alsg {
max-height: calc(100% - 40px) !important;
}
div#overlay div.intro {
color: #FFF !important;
font-size: 12pt;
margin-bottom: 10px;
}
div#overlay div.box, div.template div.box {
padding: 3px 5px;
overflow: hidden;
font-weight: bold;
position: relative;
flex-grow: 1;
}
div#alsg div.box {
text-align: center;
position: relative;
overflow: auto !important;
margin: 10px 0px 0px !important;
}
div.box {
background-color: #FFF;
color: #27374A;
border-radius: 8px;
border: 3px solid #FBE96E;
position: relative;
margin: auto;
flex-shrink: 1;
}
.fit {
max-width: calc(100% - 4px) !important;
max-height: calc(100% - 4px) !important;
}
div.popup-buttons {
margin-top: 10px;
}
#overlay .button.right {
margin-left: 10px;
}
#button-alsg-done {
margin-top: 10px;
flex-basis: 25px;
}
div.button-green {
background-color: #2CC55D;
color: #FFF;
font-weight: bold;
}
div.button-state-action {
height: 25px;
padding: 0px 5px;
line-height: 25px;
text-align: center;
border-radius: 4px;
font-size: 10pt;
font-weight: normal !important;
width: 60px;
cursor: pointer;
margin-bottom: 5px;
}
div.button {
height: 22px;
padding: 0px 2px;
line-height: 22px;
text-align: center;
border-radius: 4px;
font-size: 9pt;
width: 42px;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
}
.right {
float: right;
}
.clear {
clear: both;
}