What is the best way to create a responsive vocabulary list in columns using CSS and HTML?

Are you looking to create a unique vocabulary list using HTML & CSS with a special formatting?

Header (space space space space) Header 2
1. number one text (space space s) 4. number four
2. number two (space space space) 5. number five
3. number three text (space space ) 6. number six

If you resize your browser, the list will change to:

Header
1. number one
2. number two
3. number three

Header 2
4. number four
5. number five

The usual methods like using tables or lists with padding do not achieve this dynamic effect when resizing the browser.

Answer №1

To create a layout that adjusts based on browser viewport width, consider using floating DIV elements.

<div style="float:left; padding: 5px 30px 5px 5px; width:400px">
  <h1>Heading 1</h1>
  <ul>
    <li>Number one</li>
    <li>Number two</li>
    <li>Number three</li>
  </ul>
</div>
<div style="float:left; padding: 5px 30px 5px 5px; width:400px">
  <h1>Heading 2</h1>
  <ul>
    <li>Number four</li>
    <li>Number five</li>
  </ul>
</div>

When the browser viewport is wider than ~800px, the DIVs will be displayed side by side. As you reduce the viewport width, the second DIV will move below the first DIV.

Answer №2

To achieve this layout, you can utilize CSS with the float property. By using float, you can display two elements side by side within a container. However, if the total width of both elements exceeds that of the container (considering borders), they will stack on top of each other. Feel free to customize the styling to your liking; UL/LI are not necessary and you could even use a table within the div element.

​#table1 {
    border: 1px solid #000;
    float: left;
    width: 200px;
}

#table2 {
    border: 1px solid #000;
    float: left;
    width: 200px;

}

<div id='table1'>
    <h1>Head 1</h1>
    <ul>
     <li>Item 1</li>
     <li>Item 2</li>
     <li>Item 3</li>
    </ul>
</div>
<div id='table2'>
    <h1>Head 2</h1>
    <ul>
     <li>Item 4</li>
     <li>Item 5</li>
     <li>Item 6</li>
    </ul>
</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

Adjust the background color of a list item using Typescript

At the top of my page, there's a question followed by a list of answers and the option to add new ones. You can see an example in the image below. https://i.stack.imgur.com/NPVh7.jpg The format for each answer is "(username)'s response: at this ...

Issue with concealing floated elements within a container div

I am currently facing an issue with trying to hide floated divs within a parent div, but unfortunately my code is not working as expected. Here is the code snippet: div.scrollarea { overflow: scroll; width: 400px; ...

Unexpected behavior with overflow:scroll in the <body> tag

Take a look at this image and code snippet: <!doctype html> <html> <head> <style> body { border: 1px solid red; padding: 20px; overflow: scroll; ...

utilizing window.location.href to direct to a page with javascript capabilities

I am currently developing my own personal website. It is designed to be very light in terms of loading and content. This website relies heavily on the use of jquery, so if a user's browser does not have JavaScript enabled, the site will not function ...

What could be causing the unexpected display of my Bootstrap 4 card headers?

I am currently in the process of upgrading a website from Bootstrap 4 Alpha 6 to Bootstrap 4 Beta 1. Within my cards, there is an icon accompanied by some right-aligned text. In the Alpha version, my cards appeared exactly as I wanted them to: +---------- ...

How about some reusable skinning script?

As a .net developer diving into DNN, I'm eager to learn how to create reusable code for my skins. My goal is to have the header and footer sections stored in a file (similar to a master page) so that when creating my skin for the website, I can easily ...

What is the solution for correcting the currency formatting in a text input field?

Hello everyone, I have a question about formatting numbers in my code: I want to format numbers like this: 001 -> 0,01 || 10000 -> 100,00 || 10012300 -> 100.123,00 and so on... However, the issue is that my current code only adds the ',&apo ...

I would appreciate your assistance in the modification of the input type from text to radio within the PHP code

I've been struggling to update the input type from text to a radio button for Gender selection in my Wordpress theme's user profile settings. I can't seem to get it right in the code and I'm not sure how to make the change. I tried usi ...

Tips on using PHP to populate a Bootstrap popover

Although this question may have been asked previously, I have gone through the answer, tried to implement it, but I am encountering a small issue. While working on a PHP file, I attempted to create an anchor tag and display it in a popover. However, inste ...

Is there a way to specifically retrieve the number of likes or followers from Facebook, Twitter, Instagram, and Snapchat in order to display them on my HTML website?

Can you provide guidance on how to obtain the total numbers of likes or followers for our Facebook, Twitter, Instagram, and Snapchat pages without including the plugin boxes or buttons? We are solely interested in the actual numbers. Would this be feasibl ...

Running a MySQL query within a WordPress post using shortcode? Keep it in the post and avoid sending it to the footer with

My MySQL code is functioning perfectly, and I have created a custom shortcode to embed the content within a post. However, I am facing an issue where the shortcode is executing below the footer. Initially, I suspected it was a problem with a plugin or them ...

Step-by-step guide on displaying a window containing text when hovering over a CSS class

As a beginner in css, html, and js, I created an html page with a table of athletes. Each row is identified by the css class "athlete-name", like this: <div id="message-hide" style="display: none"> Hello world! </div> <t ...

Set tab navigation widget with a fixed height

I am struggling with setting a fixed height for my tabs widget so that when I add more content, it will display a scrollbar instead of expanding endlessly. I have checked the CSS and JS files but cannot figure it out. It is important for me to contain this ...

Utilizing Bootstrap to emphasize the selected navbar item by adding the active class upon

I was attempting to emphasize the clicked navbar by adding an active class. This is the code I tested: <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> < ...

Adjusting ThreeJS Canvas to Utilize Entire Space

Here is a simple example I created for demonstration: http://jsfiddle.net/8nbpehj3/37/ <html> <body> <div class='wrapper'> <div class='nav'> <div class='button'>Button</div ...

Making Bootstrap div stretch vertically with absolutely positioned content

Is there a way to make the middle div expand vertically on screen sizes smaller than 1000px without causing the text to flow under the image in the third div? Even clearing floats doesn't seem to solve the issue. This code is based on Bootstrap 4.4. ...

Unable to create a responsive layout because of the use of inline CSS with "margin"

Currently, I am working on a design for a webpage that must be responsive to large, medium, and small screens. To achieve this responsiveness, I am using Material UI Grid container and placing Chips inside it with the style={{ marginLeft: 60 }} from the se ...

only a single backdrop filter can be in use at any given moment

Experimenting with backdrop-filter in Chrome 76. I'm working on a menu with 2 divs, each with a backdrop-filter applied. The first div is displaying the filter effect perfectly, but the second one isn't. Interestingly, when I remove the filter fr ...

What is the method for superimposing a div with a see-through input field?

I am currently designing a compact upload feature. It consists of a responsive element (actually a vue/quasar card) that adjusts in size according to the window dimensions and viewport. Within this element, there is a form containing an input field and a ...

The height of Material-UI Grid item is surpassing the height of its container

I'm encountering an issue with a Grid container that contains 2 Grid items. The height of the second Grid item exceeds the height of the container, causing a scroll bar to appear. Below is the code snippet for reference: function App() { return ( ...