I am trying to attach a tooltip to a button.
.hangup_button {
display: block;
margin-left: auto;
margin-right: auto;
margin-bottom: 25px;
}
.contained_message {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
}
.messageContain:hover .contained_message{
visibility: visible;
}
<div class="container_div">
<button class="hangup_button messageContain">
End Chat
<span class="contained_message">Terminate session. Charges stop accumulating.</span>
</button>
</div>
The problem I have is that the tooltip appears at the bottom of the button. I am trying to make it appear to the top of the button. So far, I tried to switch the <span class="contained_message"> to the top of the End Chat text. But the tooltip still exceeds the bottom of the button. I also tried to add position: relative; to .contained_message. That seems to mess up the whole button. What should I do in order for the tooltip to appear on top of the button, without exceeding the bottom of the button?
I added some changes to make it work:
Use position: relative on parent element.
Use transform: translate to get the desired placement, as well as top: -5px (can be 0, but -5 gives it a nice space)
I changed it to display: none / block instead of using visibility, as it may be more desirable (providad you are not looking to do transitions).
To center the tooltip horizontally, left: 50% with translate(-50%, ...) does the trick.
Working snippet:
.hangup_button {
display: block;
margin-left: auto;
margin-right: auto;
margin-bottom: 25px;
margin-top: 80px;
position: relative;
}
.contained_message {
display: none;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
transform: translate(-50%, -100%);
left: 50%;
top: -5px;
}
.messageContain:hover .contained_message{
display: block;
}
<div class="container_div">
<button class="hangup_button messageContain">
End Chat
<span class="contained_message">Terminate session. Charges stop accumulating.</span>
</button>
</div>
Related
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.
Does anyone know why the following issue occurs only in Firefox browser? And how to fix that?
When the user wants to use the keyboard with the Firefox browser unexpected behavior occurs around . menu-button button.
If you press tab after the . menu-button button you don't come out on the next ‘test 2’ button as expected, but the focus seems to disappear. If you then press TAB two more times you do end up on ‘test 2’ button.
Our research showed that the span with the attribute data-email="long" has the css property display: inline-block and that makes this span focusable. The display inline-block on [data-email="long"] span is needed so that the long email hooks off behind the white gradient.
You can find a demo of the issue here (test it in Firefox):
/* base */
html, body {
padding: 20px;
}
ul {
display: flex;
list-style: none
}
li {
position: relative;
}
button {
margin: 10px;
}
.menu-button {
display: inline-block;
position: relative;
color: #003082;
cursor: pointer;
font-weight: 700;
line-height: 1.5625rem;
width: 85px;
text-align: left;
&:focus {
&::after {
content: '';
display: block;
position: absolute;
top: -4px;
left: -4px;
right: -4px;
bottom: -4px;
border-radius: 4px;
border: 1px solid blue;
box-shadow: 0 0 0 1px #0063d3, 0 2px 28px rgba(#000, 0.1);
}
outline: none;
}
}
.menu-button-text {
margin-right: 0;
&::before {
content: "";
height: 2.1875rem;
width: 2.1875rem;
position: absolute;
left: -3px;
top: -4px;
}
}
[data-email=long] {
display: inline-block;
width: 68px;
overflow-x: hidden;
vertical-align: top;
&::after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 3rem;
height: 100%;
z-index: 1;
opacity: 1;
background: linear-gradient(90deg,hsla(0,0%,100%,0),#fff 90%);
}
}
/* utils */
.unbutton {
border: none;
background: none;
padding: 0;
}
.alt {
position: absolute;
-webkit-clip-path: polygon(0 0,0 0,0 0,0 0);
clip-path: polygon(0 0,0 0,0 0,0 0);
width: 1px;
height: 1rem;
margin: 0;
overflow: hidden;
white-space: nowrap;
}
<ul>
<li>
<button>
test 1
</button>
</li>
<li>
<button class="unbutton menu-button">
<span class="alt">logged in with:</span>
<span class="menu-button-text menu-button-text--full">
<span class="h-acc-visible-l" data-email="long" >test#test.com</span>
</span>
</button>
</li>
<li>
<button>
test 2
</button>
</li>
</ul>
Only the button must be focusable and not the span(s)
Dirty, but: Set your buttons with attribute "tabindex" and positive values (1 to 3), while all your spans inside button #2 get tabindex="-1"; just tried your fiddle with this mod and works at least in FF85.
I'm working on an alternate display for a presentation program that replaces an HTML div with the text of the slide.
I want to have the bottom of the text aligned to a certain point, so that it has the same bottom point regardless of the number of lines.
I have now put that div inside another (id="wrapper") in order to get it to align at the bottom. The screen will always be 1920x1080. I've used the following CSS:
#wrapper {
height: 1040px;
}
#currentslide {
display: inline-block;
background-color: rgba(0,0,0,0.8);
color: white;
text-align: center;
line-height: 1;
font-size: 32px;
padding: 10px;
vertical-align: bottom;
position: absolute;
left: 50%;
transform: translate(-50%);
}
<div id="currentslide"></div>
The inline-block is to give a background that changes with the text width, but I think it's interfering with my placement.
Thanks for any help!
Figured it out. I used:
#wrapper {
height: 1080px;
}
#currentslide {
display: inline-block;
background-color: rgba(0,0,0,0.8);
color: white;
text-align: center;
line-height: 1;
font-size: 32px;
padding: 10px;
position:absolute;
bottom: 40px;
left: 50%;
transform: translate(-50%);
}
I am using font awesome icons and I want them position on top of each other. I also want to the user to be able to interact with them by clicking on them.
The problem is that the element of each icon is taking up more space than it needs and is overlapping. So when the user thinks they are clicking on the top one, they end up activating a listener for the bottom one.
Here is the html:
<div class="arrow-container">
<i class="fa fa-sort-asc comment-vote up-vote-comment" aria-hidden="true"></i>
<i class="fa fa-sort-desc comment-vote down-vote-comment" aria-hidden="true"></i>
</div>
and the css:
.black-arrow{
color: black;
}
.up-vote-comment{
width: 100%;
}
.down-vote-comment{
position: relative;
top: -15px;
}
.comment-vote{
font-size: 20px;
}
it is important for me that the two arrows line up exactly on the same line horizontally and be quite close vertically, as they are in this fiddle.
Anyone know how to make them not overlap in occupied element space? I tried setting the height of the bottom arrow but that just made the occupied space of the element be above the arrow itself.
You can use the following code:
EDIT
.comment-vote {
font-size: 20px;
position: initial;
width: 100%;
display: inline-block;
}
.arrow-container {
width: 30px;
position: absolute;
top: 0px;
left: 0px;
}
This way you can use the .arrow-container class to position the arrows.
Combination of containers and absolute positioning. You can even have a 2px space between arrows.
.comment-icon-wrapper {
height: 10px;
width: 12px;
overflow: hidden;
position: relative;
margin-bottom: 2px;
}
.comment-vote {
position: absolute;
display: block;
}
.comment-vote {
font-size: 20px;
line-height: 20px;
display: block;
background-color: red;
}
.comment-vote:hover {
cursor:pointer;
}
.down-vote-comment {
position: relative;
top: -9px;
background-color: blue;
}
https://jsfiddle.net/w6ybL3nb/5/ (backgrounds to highlight spaces)
If you add a height to the top arrow and some z-indexes so the top arrow stacks over the bottom arrow, you can achieve what you want:
.black-arrow {
color: black;
}
.up-vote-comment {
width: 100%;
height: 12px;
z-index: 2;
overflow: hidden;
}
.down-vote-comment {
top: -13px;
z-index: 1;
}
.comment-vote {
font-size: 20px;
display: inline-block;
position: relative;
}
Updated fiddle - I have added console logging to the click of the arrows so you can see which one is being pressed
I am trying to make it so that the button that I have centered on the screen (when the screen is full size, it is centered) stays in the center while still scaling down to fit to smaller screens.
I have tried some of the answers I found here and other places about changing position: absolute; and wrapping the button in a div with text-align: center; and margin: auto; but so far the button ends up not staying centered.
Here is what I have:
.wrapper {
text-align: center;
margin: auto;
}
#mybutton {
position: absolute;
left: 37%;
text-align: center;
cursor: pointer;
bottom: 10%;
letter-spacing: .55rem;
max-width: 50%;
background: #3498db;
background-image: linear-gradient(to bottom, #3498db, #2980b9);
text-shadow: 1px 1px 3px #666666;
font-family: Arial;
color: #ffffff;
font-size: 30px;
padding: 10px 20px 10px 20px;
text-decoration: none;
border-color: #3498db;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
This is probably something very simple that I am missing, but it's late and I am tired of messing around with this, so if anyone can offer any help, it would be appreciated!
Make it simple. You just need text-align:center with width.
CSS i have used
width:50%;margin:0 auto;text-align:center;
see here
try this , it is working .
.button1 {
text-align: center;
}
.button1 a {
background-color: #03326c;
font-size: 25px;
height: 35px;
position: relative;
text-align: center;
display: inline-block;
color: white;
padding: .5em 1em;
}
<div class="button1">
<span class="Button1">BUTTON</span>
or you can put button also.
</div>
This is what I understood of your problem: you wanted to make a button that scaled in accordance with the screen size AND you wanted it to be be centered.
I've pretty much done what you've been trying to do and achieved this.
.wrapper{
text-align: center;
}
button{
width: 50%;
...
}
Assigned the text align center property to the button's parent div and assigned the button a relative width.
body {
position: relative;
}
button {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
<body>
<button>CLICK ME</button>
</body>
see my pen for further explanation on how I used transform property of css