What could be causing my tabs to shift to the vertical side when using large, larger, and wide screens?

In my previous research, I came across a question similar to mine: Pure CSS accordion not working within CSS tabs. The solution mentioned works perfectly on monitors of any size, but the difference lies in the use of the a element. In their code, setting the border property to .w3c results in the border appearing externally rather than centrally or internally.

The pure CSS tabs function flawlessly on small and medium monitors, but fail to work properly on big, bigger, and wide monitors where they are shifted to the vertical side.

I experimented with changing the CSS grid properties like display and flex-wrap on the element .tabs-ids, but the issue persisted only on larger screens. Alternative attempts were made on elements such as .tabs-label and .tabs-panel without success.

You can test the sample by ensuring responsive design is set to 2400px:

Answer №1

, you'll find a flex container by the name of .tabs-ids that holds both the tab buttons and their respective content to display upon clicking. The reason why, on wider screens, the elements remain on the same line instead of wrapping to the next line (referred to as "my tabs moving to the vertical side on big screen") is due to the flex layout organizing these elements based on their size relative to their content. To counteract this behavior, one simple solution is to apply a distinct style to the element containing the actual displayed content. By adding a new class to these particular elements and ensuring they occupy 100% of the width within their container, they will automatically wrap onto a new line when necessary. In your code's style section, the sole adjustment I made was incorporating the following snippet: .tabs-panel.actual-content { width: 100%; } Additionally, I assigned the 'actual-content' class to the elements housing the text content for proper styling.

Followed by some CSS code defining variables and styling instructions, including classes like .ids-markdown, .tabs-ids, .tabs-input, .tabs-label, .tabs-panel, and more to enhance the overall design and functionality of the tabs feature being implemented in your project. This segment showcases a sample structure utilizing the provided CSS styles with HTML markup exemplifying the tabs interface setup and content organization:

:root {
  --ids_color_action_neutral_base: #3B3B3B;
  ...
<div class="ids-markdown">
  <div class="tabs-ids">
    <input class="tabs-input" id="tab-ids-1" name="tabs-ids" type="radio" checked>
    ...
</div>

You have a flex container .tabs-ids holding the elements being both the tab buttons and the actual content to be shown when such buttons get clicked.

The reason why on wider screen the elements are kept on the same line instead of wrapping on the next line (what you called my tabs moving to the vertical side on big screen) is because your flex layout arranges those elements according to their size based on their content.

What you need to avoid that behaviour is to style differently the element with the actual content to be shown.

If you simply add a new class to the elements containing the actual content you can style those to make sure they take 100% width of their container and they will surely wrap on the next line.

This was the only modification I did to the style section of your code:

.tabs-panel.actual-content {
  width: 100%;
}

Plus I added the actual-content class to the elements containing the text content.

:root {
  --ids_color_action_neutral_base: #3B3B3B;
  --ids_color_bg_base: #FFFFFF;
  --ids_color_bg_variant_01: #F1F2F4;
  --ids_color_border_soft: #CFD1D3;
  --ids_size_cornerRadius_button: 0.75rem;
  --ids_size_cornerRadius_tags_01: 0.25rem;
  --ids_size_border_small: 0.0625rem;
  --ids_size_general_8x: 0.5rem;
  --ids_size_general_20x: 1.25rem;
}

.ids-markdown {
  font-family: sans-serif;
  margin: 10px;
  width: 100%;
}

.ids-markdown .tabs-ids {
  display: flex;
  flex-wrap: wrap;
  background: none;
  border: var(--ids_size_border_small) solid var(--ids_color_border_soft);
  border-bottom-left-radius: var(--ids_size_cornerRadius_tags_01);
  border-bottom-right-radius: var(--ids_size_cornerRadius_tags_01);
  border-top-left-radius: var(--ids_size_cornerRadius_button);
  border-top-right-radius: var(--ids_size_cornerRadius_button);
  margin: 20px;
}

.ids-markdown .tabs-ids .tabs-input {
  position: absolute;
  opacity: 0;
}

.ids-markdown .tabs-ids .tabs-label {
  border-right: var(--ids_size_border_small) solid var(--ids_color_border_soft);
  color: var(--ids_color_action_neutral_base);
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: background 0.1s, color 0.1s;
  /* width: 100%; */
  width: auto;
  align-items: center;
  display: flex;
  filter: saturate(0);
  justify-content: center;
  padding: var(--ids_size_general_8x) var(--ids_size_general_20x);
}

.ids-markdown .tabs-ids .tabs-label img {
  height: 1.625rem;
}

.ids-markdown .tabs-ids .tabs-label:hover,
.ids-markdown .tabs-ids .tabs-label:active {
  filter: saturate(1);
}

.ids-markdown .tabs-ids .tabs-input:focus+.tabs-label {
  z-index: 1;
}

.ids-markdown .tabs-ids .tabs-input:checked+.tabs-label:nth-child(2) {
  border-top-left-radius: var(--ids_size_cornerRadius_button);
}

.ids-markdown .tabs-ids .tabs-input:checked+.tabs-label {
  background-color: var(--ids_color_bg_variant_01);
  color: var(--ids_color_action_neutral_base);
  filter: saturate(1);
}

.ids-markdown .tabs-ids .tabs-panel {
  background-color: var(--ids_color_bg_variant_01);
  border-top: var(--ids_size_border_small) solid var(--ids_color_border_soft);
  display: none;
  order: 99;
}

.ids-markdown .tabs-ids .tabs-panel section {
  background: var(--ids_color_bg_base);
  padding: 20px 30px 30px;
}

.ids-markdown .tabs-ids .tabs-panel .pre {
  border: unset;
  border-radius: unset;
  border-bottom-left-radius: var(--ids_size_cornerRadius_tags_01);
  border-bottom-right-radius: var(--ids_size_cornerRadius_tags_01);
  margin: 0px;
  width: 100%;
}

.ids-markdown .tabs-ids .tabs-input:checked+.tabs-label+.tabs-panel {
  display: block;
}

.tabs-panel.actual-content {
  width: 100%;
}
<div class="ids-markdown">
  <div class="tabs-ids">
    <input class="tabs-input" id="tab-ids-1" name="tabs-ids" type="radio" checked>
    <label class="tabs-label" for="tab-ids-1"><img src="https://cdn-icons-png.flaticon.com/128/546/546049.png" alt="Linux"></label>
    <div class="tabs-panel actual-content">
      <section>
        <h1>Arlina Design</h1>
        <p>Arlina Design (specifically, the sweet orange) is the fruit of the citrus species Citrus × sinensis in the family Rutaceae</p>
        <p>The fruit of the Citrus × sinensis is considered a sweet orange, whereas the fruit of the Citrus × aurantium is considered a bitter orange. The sweet orange reproduces asexually (apomixis through nucellar embryony); varieties of sweet orange arise
          through mutations.</p>
      </section>
    </div>
    <input class="tabs-input" id="tab-ids-2" name="tabs-ids" type="radio">
    <label class="tabs-label" for="tab-ids-2"><img src="https://cdn-icons-png.flaticon.com/128/1532/1532546.png" alt="macOS"></label>
    <div class="tabs-panel actual-content">
      <section>
        <h1>Idntheme</h1>
        <p>Idntheme (Citrus tangerina) is an orange-colored citrus fruit that is closely related to, or possibly a type of, mandarin orange (Citrus reticulata).</p>
        <p>The name was first used for fruit coming from Tangier, Morocco, described as a mandarin variety. Under the Tanaka classification system, Citrus tangerina is considered a separate species.</p>
      </section>
    </div>
    <input class="tabs-input" id="tab-ids-3" name="tabs-ids" type="radio">
    <label class="tabs-label" for="tab-ids-3"><img src="https://cdn-icons-png.flaticon.com/128/1532/1532543.png" alt="Windows"></label>
    <div class="tabs-panel actual-content">
      <section>
        <h1>Tekno Match</h1>
        <p>Tekno Match (Citrus ×clementina) is a hybrid between a mandarin orange and a sweet orange, so named in 1902. The exterior is a deep orange colour with a smooth, glossy appearance. Clementines can be separated into 7 to 14 segments. Similarly to
          tangerines, they tend to be easy to peel.</p>
      </section>
    </div>
  </div>
</div>

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

Clicking on a button within the parent element will enable you to remove the parent element multiple times with the use of VanillaJS

Within a ul element, each li contains multiple elements in the following structure: <ul> <li> <div> <p>some text </p> <button>delete</button> <div> </li> <li> ...

The link and source attributes are missing from the .ejs template

I am experiencing an issue where the href and src attributes in my .ejs file are not referencing my local files properly. My setup involves node.js and express. Here is a snippet from the .ejs template that is causing the problem. <head> & ...

How do I ensure that my absolutely positioned element is centered in this specific scenario?

I've been working on centering an element within its parent container, and I'm having trouble ensuring it remains centered responsively. Here's what I have so far: HTML <div class="example"> <span class="element1">Element ...

Utilizing jQuery to Maintain State Across Page Refreshes with Cookies

Currently, I am attempting to create a script that can retain its state even after the page is refreshed. Here is my progress so far: Utilizing jQuery: $(window).ready(function() { var voteId = $('.gallery-item a'); $(voteId).click(function() ...

Accessing JS code from HTML is not possible in React

Attempting to create a list using React, I have utilized the module found here: https://github.com/pqx/react-ui-tree I am currently testing out the sample application provided in this link: https://github.com/pqx/react-ui-tree/blob/gh-pages/example/app.js ...

Could someone lend a hand in getting the X to align properly on this div? I've been struggling with it for ages and just can't seem to crack

This is a demonstration of the CodePen project: Click here to view <div class="annotation"> <div class="annotext"> <div class=annobar></div> <div class="x">✕</div> Lorem ipsum dolor sit amet, consectetur adipiscing e ...

What steps can I take to create a textbox that expands as more text is

Looking to create a unique textbook design that starts out with specific width and height dimensions, but expands downward as users type beyond the initial space. Wondering if CSS can help achieve this functionality? In a standard textbox, only a scroll ba ...

Ways to update list item text with jQuery

I am attempting to create a button that can replace the content of a list item. Although I have looked at other solutions, I keep encountering this error message: Uncaught TypeError: Object li#element2 has no method 'replaceWith' I have experime ...

Notify the user immediately if an HTML template is stolen using Jquery and PHP

After uploading an HTML template to themeforest, I discovered that some websites were giving away the full source code for free. Since HTML is easy to copy, obfuscation doesn't solve the issue. Is there a way to use JQuery to alert me if someone hosts ...

creating a vertical scroll bar for an HTML table's content

How can I set a fixed height for my HTML table on a webpage so that if it exceeds the height, a vertical scrolling bar is automatically displayed? Any assistance would be greatly appreciated. Thank you. ...

Maintain the background div while scrolling horizontally

I am facing an issue with my wide bar chart where I use iScroll to enable horizontal scrolling. Behind the bar chart, there are horizontal lines that should move along in the background as the user scrolls horizontally. The challenge is to keep the lines v ...

Creating a variable with the use of @include

Here's a question that I need help with. I have a SASS @include function that dynamically calculates the font size. h2 { @include rfs(2rem); } I use this to adjust the font size based on screen resolution, but I'm facing an issue where a gre ...

Has a newly created element been styled or are all values set to default since it is outside of the DOM?

First, I begin by creating an element: let link = document.createElement('a'); After my document is fully loaded and all styles and scripts are applied. The styles may look something like this: a { background-color: salmon; } Therefore, it w ...

Add CSS styling to input text that is not empty

Is it possible to achieve this using CSS3 alone? var inputs = document.getElementsByTagName("INPUT"); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == "text") { if (inputs[i].value != "") { inputs[i].s ...

Analyzing an HTML document

My current challenge involves extracting the username from an HTML Page based on who is accessing it. The username is displayed on the page, but its location may vary depending on the user. I'm curious to hear how others would approach this issue. My ...

Using Thymeleaf to display <TR> elements according to specific conditions

Is there a cleaner way to show content only if one object is not null? No annotations found in this block of code. Here is the template: <div th:if="${currentSkills != null}"> <tr ><!-- Data File --> <td class="col_id"> ...

The ion-content scrolling directive is failing to show any displayed information

Within my Ionic application, I have a very simple HTML structure: <ion-pane> <ion-header-bar class="bar-stable"> <h1 class="title">Ionic Blank Starter</h1> </ion-header-bar> <ion-content> ...

What is the best way to conceal a sticky footer using another element?

I have a footer that remains fixed at the bottom of both long and short pages. Below is the CSS code for this footer: .footer{ position: absolute; bottom: 0; width: 100%; height: 100px; background-color: white; } My goal is to achieve a 'r ...

Adjust CSS to properly position links alongside details summary

Currently enhancing my Hugo site (repository link is here). I am aiming to integrate a details element alongside anchors, maintaining a consistent style. The desired layout is depicted in the initial screenshot where "abstract" serves as the details elemen ...

What is the process for adding a download link to my canvas once I have updated the image?

Is it possible to create a download link for an image that rotates when clicked, and then allows the user to download the updated image? Any help would be appreciated.////////////////////////////////////////////////////////////////////// <!DOCTYPE ht ...