Tips for aligning buttons in a row

I am trying to find a way to make my buttons more compact within a <div> element when the length exceeds 100%. Is there a way to achieve this while avoiding wrapping to a second line?

Is there a solution similar to using scaleX, but one that takes into account the width of all available buttons?

Sample Code:

<div class="something">
  <button>some text</button>
  <button>some other text</button>
  <button>another example</button>
</div>

Example: http://jsfiddle.net/BRNKt/ I am aiming to densify the buttons (text font) in order to keep them all on a single line within the original div width.

Answer №1

To condense the appearance, consider including button { padding: 0 }. For further adjustments, try adding

.something { word-spacing: -0.3em }; button { word-spacing: 0 }
.

As for altering font size based on width availability, it may pose accessibility issues and browser limitations. Fonts cannot always be reduced below a certain threshold set by the browser.

If breaking lines within buttons is acceptable, you can control button width and text wrapping with this method:

button { padding: 0; max-width: 14%; float: left; }

Alternatively, you can manually insert line breaks into the buttons like so:

<button>some<br>text</button>
<button>some<br>other<br>text</button>  

Answer №2

.another-class,
.another-class button {
    text-overflow: ellipsis;
}

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

The signal property 'ɵunwrapWritableSignal' is not found on the specified type 'typeof import/node_modules/@angular/core/index")'

Despite attempting the solutions provided in previous threads, none of them have been successful for me. Can someone please lend a hand with this issue? https://i.stack.imgur.com/sGRsn.png ...

Is there a way to efficiently integrate text from a webpage into a "Twitter Share" button automatically?

I have a cool feature on my website - a random quote generator where users can tweet the current quote at the click of a button. I've set up a Twitter share link using jQuery that dynamically updates with each new quote: $('.twitter-share-button ...

Unable to get Bootstrap IMG-RESPONSIVE to function properly in Firefox and IE within the navbar

I recently encountered an issue with the Bootstrap IMG-RESPONSIVE class not functioning properly in the navigation bar on Firefox and IE. Oddly enough, it was working perfectly just a few days ago until I made some unknown changes, causing it to only work ...

Troubleshooting problem with scrollbar in HTML table within a div element

I'm utilizing Bootstrap for the majority of my CSS. I've split a section into two columns, with the left column displaying a table with data and the right side featuring a Google map. The issue arises when the table row grows, as it doesn't ...

What causes the code following the </html> tag to be shifted in front of the </body> tag? Is there a noticeable improvement in performance

After exploring various Stack Overflow posts like this particular SO question, I came across an unconventional Google recommendation on CSS optimization. This recommendation suggested deferring CSS loading with markup that looked like this: <d ...

Tips for showcasing elements individually in JavaScript when a button is clicked and halting on a random element

I have some names stored in h3 tags. I want to highlight one name at a time when I click a button, stopping at a random name. <div class="all-names"> <h3 class="name-one"><span class="line">Name ...

Adjust the baseline of text in <li> elements by shifting it 2 pixels upwards

My webpage menu is set up with inline "li" elements within a "ul". Each "li" has a colored border and contains an "a" tag. I'm looking to change the text color inside the "a" tag and move it 2px up when hovering over it without affecting the li border ...

Create a notification menu in Bootstrap using Bootply, which conveniently displays a numerical badge at the top

I am interested in implementing a bootstrap notification menu similar to the one found at this link: http://www.bootply.com/oasBuRC8Kz# However, I would like to add the number of notifications to the upper right corner of the glyphicon. I have gone throug ...

Ensure that the container div is filled by the image if the image exceeds the dimensions of

I have a footer menu with a background image that is larger than the div itself (2000x168). Even though I have set the width to 100%, it seems like the whole image isn't displaying. Instead, only a portion of it is visible, matching the size of my sc ...

Avoiding white spaces in user input with Material UI (MUI)

<FormControl variant="standard"> <InputLabel className="input-box-label" htmlFor="component-helper">My Value</InputLabel> <Input id="component-helper" value={m ...

Tips for transferring input values from a JavaScript function to a separate PHP page for storage in a database

This code snippet allows dynamic rows to be added to a table when the add button is clicked. Now, the goal is to retrieve the values entered into the text boxes and submit them to the database. <div id="addinput"> <p> <button name=" ...

I have a website hosted on Heroku and I am looking to add a blog feature to it. I initially experimented with Butter CMS, but I found it to be too pricey for my budget. Any suggestions on

I currently have a website running on Heroku with React on the front end and Node.Js on the back end. I want to incorporate a blog into the site, but after exploring ButterCMS, I found the pricing starting at $49 to be too steep for my budget. My goal is ...

Exploring a GitHub image repository with HTML loops

I need assistance with incorporating a gallery into my GitHub pages website. Within my username.github.io directory, I have an assets/images folder containing various images that I want to display by looping through them. After searching for a solution, I ...

What can be done to stop a header from sticking to a table and displaying horizontally scrolling content along the border?

I need to ensure that the red headers do not overlap with the blue headers' borders while scrolling horizontally. It is essential for me to have a white border on the blue headers. .container { overflow: auto; width: 200px; } table { borde ...

Tips on how to display a gif image during the loading of ajax content using JavaScript

Currently, I am attempting to load a gif image while waiting for the AJAX data to be loaded and displayed. However, I am struggling with this task. I would appreciate any assistance on how to implement a loading gif in my code for the advanced search feat ...

Modify the size of a div based on the status of a checkbox using only HTML and CSS

Here is a small project that I created using only HTML & CSS. The goal is to modify the properties of the <div class="pro"> when the checkbox is checked. When this happens, all other <div class="pro"> elements should be hidden and the <art ...

Having an issue with a cropped CSS box?

I have created a CSS box with a red background color, but for some reason the bottom left corner is being cut off. Can you provide an explanation for this issue? (Refer to the image below) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

HTML text-indent is a way to add extra space to

I cannot understand why my text is not indenting properly. At the very bottom left corner, the "Educational Specifications" text is enclosed within a p element as follows: <p style="text-indent: 3em">Educational Specifications</p> Why doesn& ...

What method can I use in webpage coding to achieve this special highlight effect, and what is the official term for it?

Need help figuring out how to make an icon change from blue to white when selected. I've searched through Bootstrap, CSS, and HTML, but haven't found the solution yet. Any suggestions would be appreciated! https://i.stack.imgur.com/RK1PD.png ...

Change the color of the border to match the background color

I have a parent container with a unique background color. Inside the parent container, there is an unordered list (ul) with multiple list items (li), each having a distinct color and a brighter border color. Now, I am looking to extract the border color of ...