How can I make a span take up the full width within a button using CSS?

Bootstrap and custom CSS are being used for buttons, but there is an issue.

<button type="button"
        class="dropdown-item">  
        <span (click)="showI('test_data)"  
        class="text-capitalize">
        {{ selectedAction(singleBook.href) }} 
       </span>
     </button>

What seems to be the problem? The button has a width of 200px. However, the span within it only has a width of 50px, causing the rest of the button area to be unclickable... The goal is for the span button to occupy the entire width of the button...

Attempts like 'width: 100%;' or 'max-width: 100%' have not been successful...

Answer №1

The Span element does not behave as a block element by default; you must manually set it to display as such using CSS. By default, the span element is inline.

span.text-uppercase {
  display: block;
  width: 100%;
}

Answer №2

The solution provided by @GhostPengy didn't solve the issue because there was padding applied to the button element. By removing the padding and adjusting the CSS:

.dropdown-item {
    padding: 0px;
}
.text-capitalize {
    display: inline-block;
    width: 100%;
}
<button type="button" class="dropdown-item"  >  
    <span (click)="showI('test_data)"  class="text-capitalize">
        {{ selectedAction(singleBook.href) }} 
    </span>
</button>

With this adjustment, the functionality now performs as intended.

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

Determine the selected radio button

----EDIT---- I am developing a jQuery mobile application and I need to determine which radio button is selected. This is the JavaScript code I'm using: function filter(){ if(document.getElementById('segment1').checked) { aler ...

Guide to updating Django model-based form records with choices option using an HTML form

I have a pre-existing model called ShiftChange that I am trying to update. In the model-based form, I have used CHOICES as follows: from django.db import models ====== ============= ) class ShiftChange(models.Model): ...

A floating transparent Turing image transformed into a clickable image

After creating an image button with a transparent black hover effect, I noticed that the image no longer functions as a "button." However, the hover effect still works. Is there a way to maintain the button functionality while keeping the color overlay? V ...

What is the process of uploading a video and showcasing it on an HTML page?

I have successfully uploaded images and displayed them on an HTML page. Now, I am looking to do the same for videos. Here is my current code: $('#addPhotosBtn').click(function() { $(this).parents().find('#addPhotosInput').click(); }) ...

Learn the process of using Python to copy HTML code to the clipboard

I am attempting to create a simple script in Python on Windows 10 that can copy a customized text hyperlink (Example) to the clipboard and maintain its recognition as HTML when pasted, much like how Microsoft Word handles custom text hyperlinks. I have at ...

What is the best way to click on the third div class "link" using Selenium when they all have the same div class?

While working with selenium and python, I encountered a scenario where all the HTML elements have the same class "links". There are seven links on the page, each sharing the same class and similar name. I am seeking guidance on how to interact with these w ...

The Bootstrap tooltip fails to display the visual style of the tooltip, only showing the data

Following the Bootstrap documentation for tooltips, I have tried to make the tooltip function work properly. However, when I hover over the text, the tooltip text Some tooltip text! only shows up with the alt="" function, but not styled as described in the ...

What is the best way to incorporate a description box for each city on the svg map that appears when you hover your mouse over it?

I am looking to display detailed descriptions for each city in the same consistent location on my map. With multiple pieces of information to include for each city, I want to ensure that the description box is positioned at the bottom of the map. Can any ...

Slider text in Master not adjusting properly for mobile devices

I am at my wits' end trying different solutions to make this work properly. The text on the slider of my homepage appears jumbled up when viewed on a mobile device. I suspect it might be related to responsive design? Could someone please take a look ...

Unusual actions exhibited by GestureEvent.rotation in iOS webkit browsing

Utilizing JavaScript Gesture events, I've been able to detect multitouch pan/scale/rotation actions on an element within an HTML document. If you visit this URL with an iPad: , you'll be able to touch the element with two fingers and rotate it. ...

Utilizing HTML snippets for AJAX integration

Let's dive in, I may be completely off track here. I am currently working with Wordpress. On a page I am creating an HTML select menu (Main Menu) with options that correspond to each page on the site. This menu is visible on the page. In addition, ...

Ensure that the view remains consistent while navigating a table that contains expanding concealed information

My table is dynamically populated with data within a div that has overflow: scroll and height set properties. The issue I face is that the data populates from the top, making it difficult to keep track of specific rows when scrolling within the #container ...

The functionality of the JavaScript click function is limited to a single execution

In my dropdown menu, I have a submit function that triggers whenever any children of the dropdown are clicked. However, I now need to exclude a specific li element from this function because it requires inserting a tracking ID in a popup iFrame. The code ...

Hovering causes adjacent elements to shift to the right

Whenever I hover over one of the long <li> elements, the other elements shift to the right. To view the fiddle code, click on the link below: .footer_links{ margin-top:60px; } footer .ourServices{ ...

Retrieving data from relational databases based on specific conditions in Django

I've been encountering some challenges with rendering a particular view ('myprojects') that displays the projects associated with a user from the 'uProjects' model. To address this, I created an object_list to filter 'uProject ...

When I click on a link to redirect it, I am confronted with a bizarre rectangle that

When attempting to create redirects using images, I encountered a small issue. Take a look at this screenshot: https://i.sstatic.net/LgStu.pnghttps://i.sstatic.net/eEnNB.png This is the item in question: <p><div><a title="Home" hr ...

Instructions on how to change the color of specific text to red

Issue: While working on my testimonials page, I am facing a problem with displaying an "ADMIN" tag in red color instead of normal stars for one of the responses by an admin. I have tried various solutions like removing the ending p tag and adding quotes to ...

The HTML page won't stop refreshing

I am having trouble with my admin login page code. Instead of redirecting, the page keeps refreshing. I have searched through numerous articles but have been unable to find a solution. Here is the code: <!DOCTYPE HTML> <HTML> <head> ...

Create CSS styles that are responsive to different screen sizes and

What is the best approach to ensure that these styles are responsive on any mobile device? nav ul ul { display: none; } nav ul li:hover > ul { display: block; } nav ul { background: #0066cc; background: linear-gradient(top, #0066cc 0%, #bbbbbb 10 ...

What are some ways to accomplish this task without relying on a photo editing tool?

Is it possible to swap the image link: https://i.sstatic.net/Wa4mo.jpg with this new link: https://i.sstatic.net/hqVuQ.jpg without having to use a photo editor? Below is the CSS and HTML code: I was unable to upload the logo due to the restrictio ...