Display text when hovering over a button

My goal is to achieve something similar to the following:

<button class="addMore">+</button>

I want to create an effect like this:

when the button is hovered over.

I have searched for different solutions, but none of them match the exact behavior shown in the video.

Answer №1

To show your message, make use of the title tag:

<button class="addMore" title="click here">+</button>

Answer №2

.showMore{
  border: none;
  width: 40px;
  height: 40px;
  background-color: #f5f5f5;
  transition: all ease-in-out 0.2s;
  cursor: pointer;
}
.showMore:hover{
  border: 1px solid #999;
  background-color: #e5e5e5;
}
<button class="showMore" title="Click to expand!">Show More</button>

Answer №3

<button type='submit' title='Create a New Item'>+</button>

Answer №4

To change the background color of a button using CSS, you can use the following code:

.addMore:hover {
   background-color: #545454; //desired color code
}

You can also add a tooltip to the button by including the following HTML code:

<button class="addMore" title="click here">+</button>

Answer №5

Calling all React aficionados and future enthusiasts, I successfully accomplished this task by utilizing the reactstrap library. Here's how:

Utilizing the Tooltip component

import { Button } from 'reactstrap'

<Tooltip
  tooltipContent={
    'You cannot cancel invoices that were created automatically by memberships!'
  }
  component={
    <span id={'cancelButton'}>
      <Button
        style={{ pointerEvents: 'none' }}
        onClick={...}
        disabled
      >
        Cancel
      </Button>
    </span>
  }
/>

Tooltip.jsx

import React, { useState } from 'react'
import * as Reactstrap from 'reactstrap'

const Tooltip = props => {
  const [tooltipOpen, setTooltipOpen] = useState(false)
  const toggle = () => setTooltipOpen(!tooltipOpen)
  // Warnings for component usage
  if (!props.component) {
    console.warn('Missing component for tooltip')
  }
  if (!props.tooltipContent) {
    console.warn('Missing content for tooltip')
  }
  if (props.component && !props.component.props.id) {
    console.warn('Component for tooltip has no id (must not have spaces)')
  }
  return (
    <React.Fragment>
      {props.component}
      {props.tooltipContent && (
        <Reactstrap.Tooltip
          placement={props.placement ? props.placement : 'top'}
          isOpen={tooltipOpen}
          target={props.component.props.id}
          toggle={toggle}
          delay={props.delay ? props.delay : 750}
        >
          {props.tooltipContent && (
            <div className="row p-2">
              <div className="col-md-12">{props.tooltipContent}</div>
            </div>
          )}
        </Reactstrap.Tooltip>
      )}
    </React.Fragment>
  )
}
Tooltip.displayName = 'Tooltip'
export default Tooltip

Note the significance of using

style={{ pointerEvents: 'none' }}
on the <Button /> element and nesting the Button within a <span />

Answer №6

If you prefer not to use the title attribute, it is possible to achieve the same effect using only HTML and CSS.

Consider this illustration:

HTML

<button class="read-more-info-icon modal-right">i<span class="hidden-info">More details about the topic...</span></button>

CSS

button.read-more-info-icon {
    vertical-align: top;
    background: #bfbfbf;
    height: 18px;
    width: 18px;
    text-align: center;
    line-height: 1;
    color: black!important;
    font-weight: bold;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
button.read-more-info-icon:hover {
    overflow: visible;
}
button.read-more-info-icon .hidden-info {
    position: absolute;
    top: 23px;
    width: 240px;
    text-align: left;
    background: black;
    padding: 10px;
    opacity: 0;
    transition: opacity .25s ease-in-out;
  color:#fff;
}
button.read-more-info-icon.modal-left .hidden-info { 
    right: 0;
}
button.read-more-info-icon.modal-right .hidden-info { 
    left: 0;
}
button.read-more-info-icon:hover .hidden-info {
    opacity: 1;
}

View the example on codepen: https://codepen.io/SitefactoryDK/pen/eYLQKvm

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing d3.js to implement a scatterplot with zoom functionality that focuses solely on zooming the axis without affecting

Having trouble creating a scatterplot with zoom functionality where only the axis is getting zoomed, not the data itself. Can anyone provide some assistance or insight on what might be wrong? If you're interested in checking out the project, here&apo ...

Can you explain the distinction between using element~element versus element+element?

Can you explain the variation between these two CSS selectors? When using them, I seem to receive the same outcome. In the HTML: <div>One</div> <p>Two</p> CSS Example #1: div+p { background:red; } This code assigns a red backgr ...

Positioning SVGs within a parent container while maintaining responsiveness

How can I anchor an SVG overlay with a circle in the bottom right corner while expanding the rest of the SVG to fill the remaining area of the container without distorting the circle? I've been able to position the SVG in the bottom right corner, but ...

Ways to determine if the user is using a mobile device with CSS

Is there a way to detect mobile users using CSS? I am working on a project that requires detecting mobile users, but I am unsure how to do so. Can you provide any guidance? ...

Unable to change the color of the tab indicator

Hello, I am currently using materializecss in conjunction with Angular 6. Just to clarify, I am solely utilizing the materializecss library and not ng2-materialize. My issue arises when attempting to customize the tab indicator background color by modifyi ...

A step-by-step guide on customizing the background color of the selected date in the MUI DatePicker

I am looking to customize the background color of selected dates in a MUI datePicker. In the image below, you can see that I want to change the blue color to a different color. Here is my code: const customStyles = makeStyles(theme => ({ datePickerC ...

Animation of CSS height when image/icon is hovered over

Having an issue with my icon when hovering. I am trying to change the img src on hover. Here is the code I currently have: #aks { width: 0px; max-height: 0; transition: max-height 0.15s ease-out; overflow: hidden; background: url("https://img. ...

How to center align SVG with text in a unique way

Having trouble vertical aligning my inline SVG within a label. Any suggestions? This is how I've attempted it: <label for="menu-check-box">More<svg class="more-icon"><use xlink:href="#more-chevron"></use></svg></labe ...

Displaying a preloaded image on the canvas

Once again, I find myself in unfamiliar territory but faced with the task of preloading images and then displaying them on the page once all elements (including xml files etc.) are loaded. The images and references are stored in an array for later retrie ...

Breaking a line within an ngFor loop

I'm working with an ngFor loop to generate multiple PrimeNG buttons. Currently, the buttons are displayed side by side on the same row, but I want each button to appear vertically on its own line. How can this be achieved? Below is the segment of my c ...

What could be causing the excess space in the right corner of my website's mobile version?

After creating a practice website deployed on Vercel, I ensured it was responsive by incorporating breakpoints for different screen sizes. However, upon viewing the dashboard page on my mobile device, I noticed some unwanted extra space in the top right co ...

Newbie: Troubleshooting Vue Errors - "Vue is not recognized"

I'm currently at the beginning stages of learning Vue and am practicing implementing it. However, I keep encountering the errors "vue was used before it was defined" and "Vue is not defined". Below are excerpts from my HTML and JS files for reference. ...

Using `left: initial` does not function properly in Internet Explorer

Unfortunately, the tooltip does not display correctly in IE as desired. This is how it should look (in Chrome): https://i.sstatic.net/dCM9z.png However, this is how it appears incorrectly in IE: https://i.sstatic.net/Tq6rY.png Here is my CSS code for ...

Roundabout Navigation Styles with CSS and jQuery

My goal is to implement a corner circle menu, similar to the one shown in the image below: https://i.stack.imgur.com/zma5U.png This is what I have accomplished so far: $(".menu").click(function(){ $(".menu-items").fadeToggle(); }); html,body{ colo ...

What is the best way to reduce the size of an image using a URL?

As I work on creating a website in React for a company, my main focus is on developing a drive repository where users can upload files. One issue that has arisen is the performance of the "photos" folder, as it contains numerous high-resolution images th ...

Is there a child missing? If so, add a class

I need to add the class span.toggle if the parent element of li does not have a child ul element. click here to view on codepen Snippet of HTML: <html lang="en"> <head> <meta charset="UTF-8> <title>No Title</title>& ...

In the XHTML mode, MathOverflow's invaluable mathematical expertise shines brightly

I am interested in incorporating the unique “piece of valuable flair™” from MathOverflow onto my website. The issue I am facing is that I want my webpage to comply with XHTML5 standards, meaning it should be served with the MIME type application/xht ...

What is causing textareas and text input fields inside sortable divs to be uneditable in all browsers except Chrome?

I have a group of draggable elements displayed using the jQuery UI widget. During testing in Chrome, everything works perfectly. However, in other browsers, there seem to be issues. It appears that Chrome handles the functionality better compared to other ...

What is the correct way to specify an image path for a background URL?

Currently, I am setting a background image for the hr tag using the following code: <hr style="height:6px;background: url(http://ibrahimjabbari.com/english/images/hr-11.png) repeat-x 0 0;border: 0;margin:0px!important"> However, I have now saved th ...