Is there a way to place labels or paragraphs directly on top of objects?

How can I center these labels on top of the items in my layout? Placing the <ion-label> has positioned the labels to the left of the items instead of centered. Is there a way to achieve top center alignment without affecting the round shape of the checkbox items? I'm not familiar with CSS so any guidance would be appreciated. I attempted to add the <ion-col>, but it caused the checkboxes to lose their rounded shape.https://i.sstatic.net/I6p1I.png

 <ion-row>
     <ion-label>Global</ion-label>
       <ion-item mode="ios" lines="none">
         <ion-icon name="globe"></ion-icon>
           <ion-checkbox></ion-checkbox>
       </ion-item>
      <ion-label>Lokal</ion-label>
        <ion-item mode="ios" lines="none">
          <ion-icon name="pin"></ion-icon>
            <ion-checkbox></ion-checkbox>
        </ion-item>
      <ion-label>Mann</ion-label>
        <ion-item mode="ios" lines="none">
          <ion-icon name="male"></ion-icon>
            <ion-checkbox></ion-checkbox>
       </ion-item>
  </ion-row>

CSS:

 @import "../../theme/mixins/checkbox-tag";
.checkbox-list {
  .checkbox-item {
    --padding-start: var(--page-margin);
    --padding-end: var(--page-margin);
    --inner-padding-end: 0px;



    ion-checkbox {
      margin-inline-end: 0px;
    }
  }
}

.checkbox-tags {
padding: 2%;


    @include checkbox-tag();

.checkbox-tag {
  padding: 4.5%;

}

CSS import:

@mixin checkbox-tag() {
    // Default values
    --checkbox-tag-color: #000;
    --checkbox-tag-background: #FFF;
    --checkbox-tag-active-color: #FFF;
    --checkbox-tag-active-background: #000;

      .checkbox-tag {
      // Reset values from Ionic (ion-item) styles
          --padding-start: 0px;
      --inner-padding-end: 8px;
          --inner-padding-start: 8px;
          --ion-item-background: var(--checkbox-tag-background);
      --ion-item-color: var(--checkbox-tag-color);

      &.rounded-tag {
              --border-radius: 2.2rem;
          }

          &.item-checkbox-checked {
        --ion-item-background: var(--checkbox-tag-active-background);
        --ion-item-color: var(--checkbox-tag-active-color);
          }



          .tag-label {
              margin: 5px;
        font-size: 50px;
        font-weight: 500;
        letter-spacing: 0.2px;
        text-align: center;
          }

          ion-checkbox {
              margin: 0px;
              // To hide the .checkbox-icon
              width: 0px;
              --border-width: 0px;
              height: 0px;
              // We cant set width and height for .checkbox-icon .checkbox-inner, so lets hide it changing its color
              --color-checked: transparent;
          }
      }
  }

Answer №1

If you desire to center and align the label at the top, use the following CSS:

display: block;
width: 100%;
text-align: center;

Answer №2

Try out this new grid system using rows and columns instead of the ionic grid. See if it can be a suitable alternative:


<div class="ui-grid ui-grid-responsive ui-fluid">
    <div class="ui-grid-row">
        <div class="ui-grid-col-2 ui-inputgroup">

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

Video background not playing on Bootstrap 5 Jumbotron

I created a sleek jumbotron design with a video background, but for some reason, the video isn't playing. I have no trouble loading the video from a URL separately, so I'm stumped as to what's causing the problem. Here's the simple HTM ...

Arrange blocks within bootstrap columns using grid css

I have a layout with two columns, each containing two blocks Currently, the mobile order is: 1 2 3 4 But I want it to be: 3 1 2 4 I attempted to use CSS grid but I am unsure how to move block 3 out of column 2. Here's the code snippet: body { ...

Is it necessary to replicate the navigation bar code on each page when using Bootstrap?

As I work on building a website using Bootstrap with multiple pages, I find myself faced with the question of how to handle repetitive elements like the navbar. Currently, I have separate HTML files for each page: Index.html, Products.html, Contact.html. ...

iOS does not support Css3 Transition

My Transition Code works on PC and android devices, but it does not work on iOS devices. I am only using HTML and CSS. /***** BOX 3 *****/ #box3 { height:240px; width:198px; border:1px solid #dedede; background-color:#fcfcfc; position:relative; overflow:h ...

Removing a background by linking a CSS file

Issue Resolved: I have found the solution. The problem was that the css document still contained html tags. Thank you to everyone who provided assistance. While designing a website using css, I encountered a situation where the site worked perfectly when ...

What is the proper sequence for executing a JavaScript function?

What task am I attempting to accomplish? I am trying to run two functions sequentially in JavaScript, but it seems that both functions are being called and executed simultaneously. What seems to be the issue? The setModalBox function throws an undef ...

Save the ID values for dialogs that are created dynamically in the store

Encountering an issue with storing values in dynamically created buttons that can open a dialog box. The dialog is the same for all buttons, so the definition looks like this: $('<div id="dialog-form" title="Change coordinates">' + ...

Utilizing jQuery for validating latitude and longitude coordinates with regular expressions

I implemented jQuery validation in the following way: $("#register-form").validate({ rules: { latitude: { required: true, strongCoord: true }, longitude: { required: true, strongCoord: true } }, messages: { yrAr: { required: &a ...

I am looking to save the session value into the search box of the appTables application by utilizing jQuery

Is there a way to save the session value in the search box of appTables by using jQuery? <?php $session = \Config\Services::session(); ?> <script type="text/javascript"> $(document).ready(function () { var searc ...

I'm working with Angular 12, Bootstrap 5, and ngPrime, and I'm looking to overlap a p-dialog with another element in my project

Is there a way in Angular 12 with Bootstrap 5 using ngPrime to overlap a p-dialog over any other element without using z-index and CSS, solely relying on PrimeNG? I have tried using z-index with: .my-class{ z-index: 2147483647 !important; } However, ...

The JQuery mouseover and mouseout functionality for CSS is not functioning properly

Struggling to create an expanding navigation bar using CSS. Managed to implement it, but ran into issues when it kept resetting after navigating to a new page. Resorted to using jQuery to resolve the problem by utilizing mouse enter and mouse leave events. ...

Content missing after centered banner

Seeking help! I need to figure out how to center text after a container. Whenever I try, it ends up either behind the banner picture or misaligned. I want both the banner and the text example to be centered, but placing the text in the right position has b ...

Modify the text of the "search" button in bootstrap4

Clicking the "Search" button on my website redirects me to How can I modify the URL from "search" to "my_search" in this link? I want the link to be I am using the Django web framework. The fix should also support queries from the form. My code vacanc ...

Issues with sending jQuery/Ajax POST requests when using ContentEditable spans are preventing proper functionality

JavaScript and jQuery have always been a challenge for me. It feels like most days, they are out to get me. Just when I feel like we're finally getting along, I fall into a pit that I can't climb out of. Currently, my goal is to make ContentEdit ...

Cease the animated loading icon once the template has finished loading in sync with the async pipe

.ts initialize() { const loadingScreen = await this.loadingService.displayLoader();//loading screen this.products$ = this.bikeShopService.retrieveData();//Observable operation } .html <ion-col size="6" *ngFor="let product of (products$ ...

The Express JS is having trouble serving the static CSS files through the router

Currently, I am encountering this issue in a larger project, so I have created a simplified version to explain it more clearly. The Tree Structure of my project is outlined below: demo |____admin | |____admin.js |____node_modules | |____static | ...

In JavaScript or jQuery, what is the most optimal method to swap out all instances of a specific string within the body content without altering the rest of the body text?

Is there a way to replace specific occurrences of a string within a web page's body without disrupting other elements such as event listeners? If so, what is the best method to achieve this? For example: Consider the following code snippet: <body ...

Adjust the color of the background when hovering with the cursor

I am currently working on a project with a menu of buttons that dynamically changes based on the elements in a list. For instance, if my list contains ["A", "B", "C"], then I would have a menu with 3 buttons. Here is how I display the buttons using a java ...

What are some effective methods to completely restrict cursor movement within a contenteditable div, regardless of any text insertion through JavaScript?

Recently, I encountered the following code snippet: document.getElementById("myDiv").addEventListener("keydown", function (e){ if (e.keyCode == 8) { this.innerHTML += "&#10240;".repeat(4); e.preventDefault(); } //moves cursor } ...

Attempting to apply styling to a div by utilizing ng-repeat

I'm attempting to modify the background color of a div using ng-repeat. The color I want is retrieved from the object in the loop. However, every time I try to do this, it sets my style property to blank. Here's the code I have been using: ...