use css to remove container div tag

Looking for a solution to adjust the display of items in this structure:

<div clas="page_cat_list">
    <div class="page_cat_row">
        <div class="page_cat_item">...</div>
        <div class="page_cat_item">...</div>
        <div class="page_cat_item">...</div>
        <div class="clear_fix"></div>
    </div>
    <div class="page_cat_row">
        <div class="page_cat_item">...</div>
        <div class="page_cat_item">...</div>
        <div class="page_cat_item">...</div>
        <div class="clear_fix"></div>
    </div>
</div>

The goal is to make page_cat_list 100% width and have as many items fit in the row dynamically.

Tried:

.clear_fix {
    display: none;
}

which works, also attempted:

.page_cat_row{
    display: inline;
}

This displays items aligned left. Tried centering with:

    .page_cat_row, page_cat_list {
    text-align: center;
}

without success. The ideal solution would involve removing the .page_cat_row element from CSS, as there's no access to the HTML.


Desired behavior depicted below:

<div clas="page_cat_list">
    <div class="page_cat_item">...</div>
    <div class="page_cat_item">...</div>
    <div class="page_cat_item">...</div>
    <div class="page_cat_item">...</div>
    <div class="page_cat_item">...</div>
    <div class="page_cat_item">...</div>
</div>

Answer №1

.page_cat_item is a div with a default width of 100%, so make sure to center align the content inside this div, not the entire div itself

.page_cat_item {
    text-align: center;
}

It looks like there was an error in the CSS you were using

.page_cat_row, page_cat_list {
    text-align: center;
}

In the CSS above, remember to include the period (.) before both classes, not just the first one

The corrected version should look like this

.page_cat_row, .page_cat_list {
    text-align: center;
}

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

Apply the CSS style to make one element identical to another, while modifying a single property

I am currently working with the following CSS: input[type="text"] { border: 2px solid rgb(173, 204, 204); height: 31px; box-shadow: 0px 0px 27px rgb(204, 204, 204) inset; transition:500ms all ease; padding:3px 3px 3px 3px; } My goal i ...

Switching the theme color from drab grey to vibrant blue

How can I change the default placeholder color in md-input-container from grey to Material Blue? I have followed the instructions in the documentation and created my own theme, but none of the code snippets seems to work. What am I doing wrong? mainApp. ...

Employing HTML5/CSS3 for classic image animation through traditional Sprite animation techniques

Currently, I am exploring the use of a sprite sheet for animation purposes. Rather than using canvas, I have opted for the HTML5/CSS3 method of displaying images on the screen. However, I have encountered a potential obstacle at the start of this process. ...

Creating a unique JavaScript script that gradually adjusts the background color using the setTimeout() function

Is there a way to create a function that continuously changes the background color every 15 seconds by picking colors from an array that starts over once all colors have been used, without having the function run just one time? $(document).ready(() => ...

Is there a way to adjust the footer to move downward automatically as new content is added to the body?

Hello friends! I encountered an issue with my website where the content in the body overlaps the footer when there is a lot of content added. I have created a navigation bar and footer separately on different pages and then included them on every page usin ...

Inject CSS values dynamically

I am currently working on dynamically setting the color of a div. To provide some context, let's examine the following: <!doctype html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <div clas ...

jQuery Toggle and Change Image Src Attribute Issue

After researching and modifying a show/hide jQuery code I discovered, everything is functioning correctly except for the HTML img attribute not being replaced when clicked on. The jQuery code I am using: <script> $(document).ready(function() { ...

Why isn't my lightbox able to read this specific property?

A gallery was created using both lightgallery and cycle2. Cycle is a carousel plugin while lightgallery is a lightbox gallery. Clicking on an image in the carousel opens it in the lightbox. Everything worked perfectly until a category in the carousel was ...

Is it possible for a div to contain more than one class in Twitter Bootstrap?

Is it possible for a div element to have multiple classes assigned to it? I am currently working with Twitter Bootstrap and I would like to utilize two predefined classes. Specifically, I want to apply the active class to a dropdown-toggle within a navig ...

The issue of jumpy CSS background on full screen mode for mobile devices is causing

While developing a web app, I encountered an issue with the responsive (parallax) full screen background. On mobile devices, the background does not extend below the toolbar, causing a jumpy effect when scrolling up and down in Firefox. I have tried differ ...

Enhance VideoJS using custom Ionic icons in a NextJS environment

I'm creating a platform for video content and I want to enhance the VideoJS player by incorporating icons from the Ionic set. However, as I typically use the <ion-icon/> tag to insert icons on my pages, I had to individually specify each icon&ap ...

How can I make the scrollbar invisible in the sticky header of a Material UI Table?

In my React project, I have implemented a Material-UI Table with a fixed header. The issue I am facing is that the scrollbar in the table header overlaps it and I want to hide it while still displaying it in the body of the table. I have attempted to modi ...

My React project is unable to import the foundation SCSS file into the App.scss file

After installing zurb-foundation using npm, I attempted to import the .scss file into my App.scss file. Utilizing the "live sass server" for compiling the .scss code into .css code, a .css file was generated but did not display any code despite successfull ...

One way to generate div elements based on the number in an input field when a button is clicked, but ensuring it only happens once

What I am attempting to achieve is: Retrieve data from a JSON file upon button click. Display the data in separate boxes, each one different for every element of the array. For instance, if the JSON provides 3 rows of data, there should be 3 distinct box ...

Using jQuery to determine if a radio button has been selected on a price calculator

Having a JavaScript code that calculates the total price based on radio/checkbox selection. JQUERY var price = 0; $('.price-input').click(function () { if ($(this).is(":checked")) { price += parseInt($(this).attr("data-price"), 10); ...

Customizing screen dimensions for a single page using jQuery mobile

I am currently facing an issue with adjusting the size of a specific page within my application. Even though I am using <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-den ...

Enhance Your Navbar in Bootstrap 3 by Creating Vertically Expanding Links Relative to Brand Image Dimensions

To best illustrate my issue, I will begin with a screenshot of the problem and then explain what I aim to achieve. Here is the current state of my navbar: Currently, the text of the links on the right side is positioned at the top. Additionally, this is h ...

The overlay of the background image is excessively oversized

After implementing the following CSS to showcase a background image: height: 90%; /* or any other value, corresponding with the image you want 'watermarked' */ width: 90%; /* as above */ background-image: url('<?php echo "study/".$_SESS ...

arranging and altering the size of elements inside a container div

I recently started working on a new project with CodePen where I am building a website from the ground up. Each section of the site is meant to be a full page, which is why I implemented the section class. Within my first section (about), I have created tw ...

Ways to ensure that a div, header, container, and other elements completely cover the viewport

Currently, I am attempting to create a header that spans the entire viewport regardless of screen size. This header will be split horizontally into 3 equal sections, each occupying one third of the header space. I experimented with setting the header hei ...