Troubleshooting the inability to set percentage values in Bootstrap styling

My goal is to create a bar with thin bars, but my use of Bootstrap limits my control over sizes.

<template>
  <div class="container-fluid mx-auto">
    <div class="row">
      <div class="square rounded-pill"></div>
      <div class="square rounded-pill"></div>
      <div class="square rounded-pill"></div>
      <div class="square rounded-pill"></div>
    </div>
  </div>
</template>

<script>
export default {
  setup() {},
};
</script>

<style scoped>
.container-fluid {
  border: 3px solid black;
  width: 100%;
  height: 20%;
}

.row {
  display: flex;
  justify-content: space-evenly;
  align-items: center !important;
}

.square {
  width: 10vw;
  height: 3vh;
  background-color: red;
}
</style>

I am facing difficulties in setting the .container-fluid height to 50%, defining the .square width and height in %, and ensuring proper alignment of items within the .row. The justify-content property works for centering horizontally, but align-items: center doesn't align vertically. How can I express sizes in % and center align the items?

Answer №1

One recommendation is to utilize viewport-based units for setting the width and height of Bootstrap elements rather than percentages. Options such as vh, vw, vmin, and vmax offer more precise control. For instance, 1vh equates to 1% of the viewport height. Refer to the code snippet below for illustration.

Regarding the align-items aspect, what specific alignment objective are you aiming for? Which element do you intend to vertically align?

.container-fluid {
  height: 50vh;
  background-color: lightgrey;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="03616c6c77707771627343362d31... crossorigin="anonymous" />
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="accec3c3d8dfd8decddcec99829e829c81ce...sLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</head>

<body>
  <div class="container-fluid">Lorem ipsum</div>
</body>

</html>

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

What is the best way to create a background image that remains hidden behind content as you scroll through a webpage?

I am looking to recreate the effect seen on the background image of this website , where the image gets covered by content as you scroll down. ...

Guidelines on Importing Azure App Service Application Settings into VUE

Our Vue app is currently hosted on Azure App Service. In the Azure Portal, we have configured application settings such as VUE_APP_API_ENDPOINT_URL under Settings\Configuration. According to the documentation, these settings become environment variabl ...

Can you explain the life cycle of Vue Apollo subscriptions?

Does the 'vue-apollo' package automatically handle unsubscribing from queries when the view changes? For instance, imagine two views are routed to '/users' and '/orders'. The '/users' view has a subscription to the ...

Twofold Arrow Styling in CSS

Can someone help me achieve this design: https://i.stack.imgur.com/eBQ1a.png I am attempting to create a double arrow using just one class. I have tried various methods, but nothing seems to be working for me. If anyone has any suggestions or can point ...

Having trouble with @babel/plugin-proposal-optional-chaining in Vue.js <script> tag

While working on my vue/vuetify project and attempting to implement optional chaining, I consistently run into an error: ./src/App.vue?vue&type=script&lang=ts& (./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??v ...

Issues with the Dropdown Menu

I'm currently working on a dropdown menu and I've encountered two issues. When I hover over the links in the main navigation bar (such as 'about' and 'connect'), only the actual words are clickable, not the entire area tha ...

Minimize the amount of space between two heading elements

Is there a way to decrease the distance between two heading tags? I want the h2 tag to be nearer to the h1 tag. Here is the CodeSandbox link for reference: https://codesandbox.io/s/rough-framework-tsk5b ...

Unable to transition slides in AngularJS on Safari iOS 9 due to malfunctions

Having some CSS classes that smoothly slide my ng-view left and right during route change, everything was working well on most browsers and phones until now. Under ios 9, the animation is not functioning properly. Instead of sliding left to right, the view ...

Can you explain the distinction between max-width and min-width in media queries for HTML and CSS?

Could you explain the distinction between max-width and min-width in media queries in HTML and CSS? @media (min-width:480px) { /* styles for smartphones, Android phones, and landscape iPhone */ } @media (min-width:600px) { /* styles for portrait tabl ...

Using d3 as a Vue component

I'm trying to create a customizable Gauge component in Vue using d3.js, but I'm having trouble with the correct import process. Here's what I have for the gauge: // Data to be fetched var name = " "; var value = 840; var gaugeMaxValue = 168 ...

steps for converting .SCSS files to .CSS in a project template

As a beginner developer, my expertise lies in HTML/CSS/JS and some fundamentals of their frameworks. Recently, I invested in this Template from template monster for a specific project () WHAT I NEED - My goal is to modify the primary theme color of the t ...

Ways to incorporate ejs partials using JavaScript

I am currently developing code to determine if a user is logged in. Depending on the user's login status, the content of the "my user" section should vary. When a logged-in user navigates to the "my user" page, an if statement is executed to confirm ...

Reset the child JSP page to its original appearance

Displayed below is a JSP page: <div id="tabs-7" style="width: 100%;"> <form:form id="deviceForm" name="" modelAttribute="" enctype="multipart/form-data"> <div class="inputWidgetContainer"> <div class="inputWidget"> <table> ...

Why is Vue Router Navigation Guard throwing an error about exceeding the maximum call stack size?

Encountering a recurring issue of maximum stack size exceeded while implementing the following code for vue router navigation guards per-route: import state from "../vuex-store/state.js"; import Editor from "../views/Editor"; const routes = [ { ...

encountering a Zend Framework error

Looking for help with printing data after an inner join of two tables in table format. I encountered the following error in the code below: Parse error: syntax error, unexpected end of file in /home/bina/public_html/studentzend/application/views/scri ...

Submit data in the manner of a curl request

Instead of using a curl command to push a file to a web server, I am attempting to create a simple webpage where I can select the file and submit it. Here is the HTML and JavaScript code I have written for this purpose: <html> <body> <i ...

How can I make this div appear on the screen?

I have recently encountered an issue with a navbar on my webpage. Despite adding all the necessary links, one of them mysteriously disappears from view. It seems to be present when inspected in the console, but it just won't display on the front end. ...

The Chrome browser's default stylesheet is overriding the styles of my website

I'm experiencing an issue with the CSS styling on one of my website pages. Here is the CSS code for formatting links: a:link, a:visited, a:active { color: white; text-decoration: none; font-weight: bold; } However, despite these styles, ...

The utilization of local storage within Backgridjs

I am creating an app using Backbone.js (Marionette Framework) along with additional functionalities like Backgrid, Backbone local storage, Backbone Radio, epoxy, and Backbone relational model. Encountered Problem: An issue arises when utilizing the local ...

What is the best way to maintain the same height for a textarea and input fields?

What is the best way to align the message input field with the name and phone input fields? I need the height of the message input field to match the combined height of the three inputs on the left. It's crucial that the borders line up perfectly. I ...