Adjusting column sizes smaller than 1/12 within the Primeng flex grid in Angular 8

In using primeng grid, a common desire is to have 2 columns behave a certain way:

  1. the first column should take up 1/13 of the total space
  2. the second column should take up the remaining space.

Many attempt different solutions like:

<div class="p-grid p-nogutter">
  <div class="p-col-1">
    toto
  </div>
  <h1 class="p-col-11">titi</h1>
</div>

However, achieving a smaller size for the 'toto' div seems to be a challenge.

The ultimate goal is to replicate a layout like this using p-grid: https://i.sstatic.net/vb1bl.png

Other attempts have been made:

Here's an example of an attempt:

<div class="p-d-inline-flex p-ai-center">
        <button appBackButton pButton pRipple type="button" icon="pi pi-arrow-left" class="p-button-rounded p-col-1 p-mr-4"></button>
        <div class="p-flex">
            <h1>titi</h1>
            <span>blablablabla</span>
        </div>
 </div>

The result can be seen here: https://i.sstatic.net/oFMWt.png

As you can see, the button is not aligned with 'titi', but with the entire second column which is not the intended result.

Answer №1

If you are working with the grid flex feature, keep in mind that it only functions effectively with sections of 12. In case you have specific height or width requirements for the div, you can opt to set the flex column to a fixed position.

<div class="p-grid p-nogutter">
  <div class="p-col-fixed" style="width:100px">
    toto
  </div>
  <h1 class="p-col">titi</h1>
</div>

For more details on utilizing fixed width columns, you can refer to the documentation provided.

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

When creating a FlipCard, you may encounter the error message "The object may be null" while using the document.querySelector() method

Having trouble creating a flipcard on Next.js with tsx. The querySelector('.cardflipper') doesn't seem to locate the object and I keep getting this error: "Possibly the object is null". Does anyone know a solution to help my method recognize ...

What could be causing my Angular 8 project to fail to start following the installation of Angular 10 CLI?

Previously, I was working on an Angular 8 project on my computer. However, I now need to install Angular 10 to run another project. To do so, I globally installed the new version with the following command: npm install -g @angular/cli After successfully ...

Encountering issues with NPM installation and a failed build process while working with

As someone new to working with Angular, I apologize if my question is basic. I've been given a new repository to work on, but I'm having trouble building it through the command line. When attempting to run npm install and npm start on my work p ...

A method for calculating the product of two selected numbers and then adding them together

I am currently working on a form that includes two select options; one for logo design and another for letterhead design. Users should be able to choose the quantity of each design, or both if they wish. For example, a user could select 2 logo designs and ...

distinguish different designs for individual components in Angular 5

My project is divided into two main parts: one for public web pages and the other for an admin control panel. Each part has its own set of CSS and javascript files for custom templates. If I include all CSS and js files in index.html, they all load at the ...

Is Next.js compatible with CSS caching?

I'm currently working on a project with Next.js (version 12.1.0) and SCSS modules. I've noticed that my CSS seems to be caching extremely aggressively, requiring me to restart the server (npm run next dev) in order to clear it. Has anyone else en ...

The NG8002 error has occurred, as it is not possible to connect to 'matDatepicker' because it is not a recognized attribute of 'input'

I've come across an issue while working on my Angular 15 application with Angular Material. I'm trying to incorporate a date picker, but after adding the code snippet below, I encountered an error. <mat-form-field appearance="outline" ...

How can I add divs to an HTML page with a Javascript animated background?

I am currently facing an issue with my JavaScript animated background, consisting of just 3 pictures. I am trying to display some Div elements on it with content inside. Here is the code snippet I have right now: In my CSS file, I have defined styles for ...

How can I display data saved from step 2 in a multi-step form with 4 steps, when I return from step 3 to step 2?

Let's consider this scenario: Imagine the user is at step 2 and types their name into <input type="text" class="form-control input-xl" ngModel name="firstName"> They proceed to step 3 but then decide to return to step 2. The information entere ...

The validation of the "data" attribute in jQuery MetaData is not working as expected

Trying to utilize the jquery metadata plugin, I have come across an element on my webpage that is structured like this: However, when I validate it using the W3C Validator, an error pops up stating "there is no attribute "data"" Is there something I over ...

Scrollable Turbo Table experiencing a problem with the PrimeNG filter dropdown

When using PrimeNG Turbo Table, I am facing an issue where the filter dropdown is getting placed inside the scrollable table. The dropdown works perfectly fine without the scrollable table. You can see it in action here. However, when the table is scroll ...

Why is it that lists always begin outside of the enclosing element?

I've always found this incredibly frustrating. Why do lists behave this way? When you set the margin and padding to 0, you would expect them to align normally with the surrounding text on the left, right? But no. That's where the text within the ...

Ways to incorporate text using css within a textarea?

I want to include an image on my webpage using the following CSS: { background-image: url(../images/icon_new_reset.png); background-repeat: no-repeat; } Is there a way to provide alternative text or overlay text on this background image? ...

Encountering difficulties including Bootstrap in React-app after attempting global installation

After using the command npm i -g bootstrap to install bootstrap, I attempted to include it in a React-app by adding import "bootstrap/dist/css/bootstrap.css";. Unfortunately, this resulted in an error being thrown. Failed to compile. ./src/index.js Modu ...

Having trouble with jQuery's scrollLeft function on elements that are not currently visible

Within a large container DIV that contains numerous other elements and has a scroll bar, an issue arises when determining the value of scrollLeft. When the DIV is visible, the scrollLeft() function returns the correct value, but when the element is hidden, ...

What is the best method for incorporating Angular 2 files into a Django template?

My application structure is set up like this: ├── project | |── templates │ │ └── index.html │ ├── __init__.py │ ├── models.py │ ├── urls.py │ ├── serializers.py │ ├── views.py ...

In Firefox, right floated elements vanish when utilizing columns

Utilizing the ol element with column-count and column-gap properties to organize the list into 2 columns, each list item contains a span element floated right. However, I am encountering an issue where the span element is not displayed for certain items li ...

What is the method for adjusting the time format?

Using the TIME data type, my data is currently displayed in the format hh:mm:ss (03:14:00). How can I change it to display in the format hh:mm (03:14)? The usual DATE type method does not seem to work: {{test.time | date: 'HH:mm'}} However, thi ...

Learn how to safely handle JSON vulnerabilities in Angular by removing the prefix ")]}'," from the JSON data

Our Webservice JSON output is designed to enhance security by starting with the prefix ")]}'," I have read several articles and learned that HttpClient offers libraries to remove this JSON prefix, but I'm struggling to find a proper example. I ...

Having trouble resolving all parameters for the service in an Angular2 test with Jasmine mocking

I am currently attempting to create a mock service for testing purposes: Production: @Injectable() export class UserService extends DtoService { // irrelevant details here. } @Injectable() export abstract class DtoService { constructor(private h ...