Hey there, I'm looking to make sure that my div is consistently bigger than my content, even with text that cannot wrap. Can you help me figure out how to

Behold the current appearance of my window: https://i.sstatic.net/iIxDS.png

Despite my efforts to maintain proper sizing, when I shrink the screen, the text (with white-space set to nowrap) ends up looking like this:

https://i.sstatic.net/uXqox.png

Is there a way to ensure that the div will always be larger than the text? I want each div element to adjust its size based on the word it contains, like making "BnS" have a smaller div than "University Visit."

Below is my CSS code for the element:

.event-nav {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    overflow-x: auto;
}

.event-nav-item {
    margin: 0px 5px;
    padding: 5px;
    min-width: 50px;
    width: auto;
    text-align: center;
    white-space: nowrap;
}

Answer №1

.event-navigation {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    overflow-x: auto;
}

.event-navigation-item {
    margin: 0px 5px;
    padding: 5px;
    min-width: 50px;
    width: auto;
    text-align: center;
    white-space: nowrap;
}

Give this solution a try, it should meet your requirements. If possible, allow the text to wrap so that any overflowed text will collapse at a certain point.

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

Utilize jQuery to set a cookie, then apply the bodyclass retrieved from the cookie upon page

I have a button that changes the body class to .blackout For this, I am utilizing js-cookie library to manage cookies. The code snippet associated with my button is shown below: <script> $('#boToggle').on('click', function(e) { ...

Tips for utilizing the ternary operator with React table accessory

If my accessor value is 1 or 0, how can I change it to either Active or Inactive? { Header: 'isActive', accessor: 'isActive' } ...

Issues arise when utilizing external scripts alongside <Link> components in ReactJS, resulting in them becoming unresponsive

I'm experiencing some difficulties with an external script when using <Link to="/">. The script is included in the main layout file index.js as componentDidMount () { const tripadvisorLeft = document.createElement("script"); tripadvisorLef ...

Ways to showcase an icon within a select options tag

Is there a way to show Font Awesome icons in select options tag? I have tried using it outside like this <i class="fas fa-chart-pie"></i> But I'm not sure how to display it within the <option> tags instead of text. <select id="s ...

Error: The function 'check' is not defined and cannot be called when the 'on

My aim is to display the "expandrepeat" div when a specific select option is chosen. Unfortunately, the code below doesn't seem to be working as intended: <script> window.check=function(elem) { if (elem.selectedIndex == 1) { documen ...

Steps to display a modal within an inactive tab:

I have been using ngx-bootstrap tabset, although I believe this issue could apply to all bootstrap tabs as well. <tabset> <tab class='active'> <angular-modal-component> </angular-modal-component> </tab> <tab> & ...

When implementing auto-generated IDs in HTML forms, rely on randomly generated values for increased uniqueness

When developing a form with multiple complex controls built as Backbone views, one wants to ensure that the labels are correctly linked to the input elements. This is typically done using the "for" attribute. However, in cases where the same control needs ...

Scrolling up the page following the addition of a new row

https://i.sstatic.net/QLBEe.png Description After clicking the plus button in the image above, a new row is created using jQuery autocomplete. https://i.sstatic.net/Xf5Et.png Description The image above illustrates the page displaying when scrolled to t ...

When the CKEDITOR is set to fullPage mode, it cannot properly apply styles from an external stylesheet that is configured in the config.contentscss setting

To create a custom StyleSet in CKEditor using styles from an external stylesheet, I configured the settings as follows: config.extraPlugins = 'stylesheetparser'; config.contentsCss = '/css/externalStyleSheet.css'; config.stylesSet = [ { ...

Aligning buttons vertically

My challenge is to arrange textboxes with buttons in a horizontal grid system, but I'm having trouble aligning the buttons vertically. I need to use a grid system so that these items can stack properly on mobile devices: <link rel="stylesheet" hre ...

The cdkDropList in Angular's drag and drop feature does not support the application of element styles

Just wanted to share my experience in case it helps someone else out there! I've been working on an Angular project where I needed to create a Trello-like application. To enable dragging elements from one list to another, I installed the Angular cdk ...

Exploring the features of material-ui's GridList

Excuse me if this question seems silly, but I've only just started learning React a few days ago. For my current project, I need to implement a 'Like' system using material-ui's GridList. There will be eight pictures where users can cl ...

"Trouble with script: external JavaScript file failing to run

The issue lies in the fact that the specified external JavaScript file is not being executed: <script src="//www.google-analytics.com/cx/api.js?experiment=YOUR_EXPERIMENT_ID"></script> Even when I try to directly access the URL, it downloads ...

Retrieving an HTML page from one location and automatically populating textboxes with preexisting values on the receiving end

I'm currently facing a dilemma. Here's the issue: I need to load an HTML page (let's call it test.html) when a button is clicked on another page (referred to as home page). The test.html page has input boxes that I want to populate with p ...

Managing authentication in React using Reflux

I recently started learning ReactJS and decided to follow this tutorial: After making some adjustments to the code to make it compatible with my setup, I was able to successfully log in. However, upon reloading the page, the SessionStore appeared to be em ...

Blackberry - Printing HTML String within a text box

My question involves dealing with HTML Strings such as <p>something</p> etc... some other html string etc... <p>something</p> I want to display this formatted string in a field. For Android, I use a WebView... For iPhone, a UIWe ...

Encountering an error while trying to run the command "npm run start" due to an issue of "EMFILE

After running npm update, my project start broke. When I try to use npm run start, it returns the following error: 10% building 0/1 entries 0/0 dependencies 0/0 modulesnode:internal/errors:484 ErrorCaptureStackTrace(err); ^ Error: EMFILE: too many ...

Showing information retrieved from MySQL on an HTML webpage without changing the layout of the page

Need some guidance on how to efficiently display data from a MySQL database using a <p> tag. When the data is minimal, the display is fine and doesn't affect the page design. But when the data volume increases, it messes up the entire design. An ...

Ways to upload an image beyond the Frontend directory

Currently, I have a react project with the following folder structure: - React Project - Frontend - src - public - data - Backend Typically, to load an image, I would place it in the Frontend/public/data folder and reference it in ...

In a MERN application, LocalStorage fails to maintain updates after a page refresh

I've encountered an issue where LocalStorage is not staying updated upon page refresh. I'm unsure of the reason behind this and where I might be going wrong. While the backend updates correctly, the LocalStorage fails to retain the updates. Here ...