Elevate the vertical dimension of a <ul> using a TAB

I'm currently working on developing a visually appealing page that will feature 4 tabs. I used

https://codepen.io/axelaredz/pen/ipome
for the tab navigation, which I think looks fantastic. However, I am facing an issue where I need each section under every tab to have a different height. Some tabs will have more content while others will have less. Looking at the CSS, I noticed there is only one fixed height of 370px for the entire UL element. Is there a way to make this code adjust the height automatically based on the content, or at least allow me to specify different heights for each tab's content? I attempted adding position: relative and height: auto to the UL but it didn't produce the desired result.

Any suggestions on how I can achieve this functionality?

Thanks, //C

<!DOCTYPE html> 
<html>
<head>
  <title>Pure CSS3 Tabs</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css" />
</head>
<body>

  <div class="page">
    <h1>Pure CSS Tabs</h1>          

    <!-- tabs -->
    <div class="pcss3t pcss3t-effect-scale pcss3t-theme-1">
      <input type="radio" name="pcss3t" checked  id="tab1"class="tab-content-first">
      <label for="tab1"><i class="icon-bolt"></i>Tesla</label>
      <input type="radio" name="pcss3t" id="tab2" class="tab-content-2">
      <label for="tab2"><i class="icon-picture"></i>da Vinci</label>
      <input type="radio" name="pcss3t" id="tab3" class="tab-content-3">
      <label for="tab3"><i class="icon-cogs"></i>Einstein</label>
      <input type="radio" name="pcss3t" id="tab5" class="tab-content-last">
      <label for="tab5"><i class="icon-globe"></i>Newton</label>
      
      <ul>
        <li class="tab-content tab-content-first typography">
          <h1>Nikola Tesla</h1>
          <p>Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist best known for his contributions to the design of the modern alternating current (AC) electrical supply system.</p>
          <p>Tesla started working in the telephony and electrical fields before emigrating to the United States in 1884 to work for Thomas Edison. He soon struck out on his own with financial backers, setting up laboratories/companies to develop a range of electrical devices. His patented AC induction motor and transformer were licensed by George Westinghouse, who also hired Tesla as a consultant to help develop an alternating current system. Tesla is also known for his high-voltage, high-frequency power experiments in New York and Colorado Springs which included patented devices and theoretical work used in the invention of radio communication, for his X-ray experiments, and for his ill-fated attempt at intercontinental wireless transmission in his unfinished Wardenclyffe Tower project.</p><p>Tesla started working in the telephony and electrical fields before emigrating to the United States in 1884 to work for Thomas Edison. He soon struck out on his own with financial backers, setting up laboratories/companies to develop a range of electrical devices. His patented AC induction motor and transformer were licensed by George Westinghouse, who also hired Tesla as a consultant to help develop an alternating current system. Tesla is also known for his high-voltage, high-frequency power experiments in New York and Colorado Springs which included patented devices and theoretical work used in the invention of radio communication, for his X-ray experiments, and for his ill-fated attempt at intercontinental wireless transmission in his unfinished Wardenclyffe Tower project.</p>
          <p class="text-right"><em>Find out more about Nikola Tesla from <a href="http://en.wikipedia.org/wiki/Nikola_Tesla" target="_blank">Wikipedia</a>.</em></p>
        </li>
      </ul>
      
    </div>
    <!--/ tabs -->
  </div>
</body>
</html>

Answer №1

Within the code snippet you provided, consider adding a unique id to one of the li elements as demonstrated below:

<li id="leonardo" class="tab-content tab-content-2 typography">
                    <h1>Leonardo da Vinci</h1>
                    <p>Italian Renaissance polymath: painter, sculptor, architect, musician, mathematician, engineer, inventor, anatomist, geologist, cartographer, botanist, and writer. His genius, perhaps more than that of any other figure, epitomized the Renaissance humanly ideal. Leonardo has often been described as the archetype of the Renaissance Man, a man of "unquenchable curiosity" and "feverishly inventive imagination". He is widely considered to be one of the greatest painters of all time and perhaps the most diversely talented person ever to have lived. According to art historian Helen Gardner, the scope and depth of his interests were without precedent and "his mind and personality seem to us superhuman, the man himself mysterious and remote". Marco Rosci states that while there is much speculation about Leonardo, his vision of the world is essentially logical rather than mysterious, and that the empirical methods he employed were unusual for his time.</p>
                    <p class="text-right"><em>Find out more about Leonardo da Vinci from <a href="http://en.wikipedia.org/wiki/Leonardo_da_Vinci" target="_blank">Wikipedia</a>.</em></p>
                </li>

Then in your CSS, refer to the newly added id within the styling rules to adjust the height accordingly.

    /**/
    /* height */
    /**/
    .pcss3t > ul,
    .pcss3t > ul > li {
        height: 390px;
    }
//leonardo is the id that has been included in the second tabs' li element
    #leonardo {
      height: 100px;
    }

Note: Adjusting the height on the ul element may not affect the desired outcome since each tab is distinct based on the li elements. However, if necessary, you can apply a similar approach by assigning an id to the ul element.

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

Tips for adjusting the color of multi-line text when hovering with the mouse

I'm facing a challenge in changing the color of text when someone hovers over it, but so far I've only been able to make it work if the mouse scrolls over the top border of the text. The text I'm testing is located in the top left corner an ...

Tips for concealing scrollbar track without the use of overflow

Issue with Mystery Scrollbar A strange phenomenon is occurring on all pages every time the user reloads - a mysterious scrollbar track appears out of nowhere. Initially, there is no sign of this scrollbar track, making it even more puzzling. Despite the ...

Valid ways to ensure that a CSS image expands outside the boundaries of the containing div

I have inserted an image using the following CSS code: .imgtemp { float:right; top:0px; left:0px; overflow:visible; width:100%; } Although I have added the div tag to display it on the page, ...

Placing a div in the corner of an image

Is there a way to position a meta-data div in the corner of every post image, even with different image sizes? For example: This is what I currently have in my loop: <div id="images"> <?php wp_get_attachment_image(); ?> </div> < ...

Challenges encountered with relative links in the layout of a static website generator resembling padrino, sinatra, or rails, involving HTML, CSS, and haml

I'm currently utilizing a static site generator to create a website that resides on a shared network folder within my workplace. This site serves as a simple tutorial platform for my colleagues; it's not hosted on a server and remains completely ...

What is the best way to eliminate the space between the image and the text located beneath it?

I am facing an issue with some whitespace between the image and the content below it. I attempted to use body{background-color:black;}, however, this overrides my color gradient in the lower part of the page. I have not experimented with using something li ...

How to use jQuery to iterate over changing elements and retrieve their data values

Exploring the potential of a collapsible panel to meet my requirements $(".sport").on("click", function() { var thisId = $(this).attr("id"); var thisChildren = $(this) + ".sportlist"; $(thisChildren).each(function(index) { }); }); <link ...

The material UI Paper component appears to be extending beyond the boundaries of the background image

I have configured the Grid component to occupy 6 on small/medium screens for a side-by-side layout and 12 on xs screens for each item. While everything looks fine in the computer view, I am facing an issue with the mobile view where the paper component is ...

Error message in JS and HTML is totally bizarre

My expertise in JavaScript is very limited, so the terms I use might not be entirely accurate. However, I'll do my best to explain the issue at hand. I'm facing a peculiar problem... I've been attempting to modify someone else's JS scr ...

Ideas for utilizing jQuery to extract data from CSS files

Hey there, I'm facing an issue on my HTML page where I have jQuery included. In my CSS file, I have quite a lot of lines and I'm trying to figure out how to read all styles for a specific element from the external CSS file rather than the inline ...

Switching the image on click of an option tag

I'm looking to create a dynamic image changing feature using two select tags in my HTML. One select tag is for the model and the other is for the color. When a user selects a model from the first dropdown, I want the image to change to reflect that mo ...

Move your cursor over a div element while utilizing NgClass

I'm currently working on implementing a hover effect on a div using an Angular ngClass directive. Within the template file, I have a div element with the class "list-item-container" that includes another div with the class "list-item." This "list-item ...

Creating dynamic HTML table headers from a multidimensional array

In need of a solution to dynamically generate an HTML table header with multi-dimensional arrays. For example, the array structure could be: $Array = ('Sr.No.'=>'', 'Subject'=>array('Maths','Sci',&ap ...

Tap on the screen to initiate a phone call using dompdf

I recently came across a recommendation to include the following code snippet to enable click-to-call functionality: <a href="tel:555-555-5555">555-555-5555</a> However, I encountered an issue when trying to implement this in dompdf. ...

Having trouble with the Wordpress JS CSS combination not functioning properly and unable to determine the cause

I recently set up a page on my WordPress site using the Twenty Seventeen theme. At the top of the page, I created a toolbar for users to easily adjust the font size and background color. Check out the image below for reference: See Image for Bar Here&apo ...

Unable to load CSS background image

As I develop a website for a fictional company to enhance my skills in HTML, CSS, and JavaScript, I am encountering an issue with loading my background image. If someone could review my code to identify the problem, I would greatly appreciate it. Check ou ...

Establish a minimum width requirement for a Bootstrap4 webpage and ensure that scrollbars are visible

As I work on designing a website, I am facing an issue with responsiveness that I am willing to accept for now. I am looking to establish a minimum width for the overall page to be around 1000px, with a horizontal scrollbar appearing if the screen width is ...

Searching for a column fails to yield any results after altering the value in

Here is a snippet of code that I am working with: <!DOCTYPE HTML> <html lang="en"> <head> <title> Exact matches overview </title> <script type="text/javascript" src="/static/s ...

Turn off hover functionality for mobile and tablet devices

Is there a way to prevent hover effects on mobile and tablet devices for an SVG file used in the img tag? scss file: .menu-link:hover { img { filter: invert(40%) sepia(90%) saturate(2460%) hue-rotate(204deg) brightness(93%) contrast(93%); } .side ...

Animate a box moving continuously from the right to the left using jQuery

I'm trying to create a continuous motion where a box moves right, then left, and repeats the cycle. However, I can only get it to complete one cycle. $(document).ready(function() { function moveBox() { $('#foo').css({ 'ri ...