Center content in card - vmware-clarity

I wonder how to center vertically and horizontally the content of a card text (or card block).
Here's the code I'am using
<div class="clr-row">
<div class="clr-col-2">
<div class="card">
<div class="card-header">This month credits used</div>
<div class="card-block">
<div class="card-text" *ngIf="credits.length > 0">
<h1>{{creditsCurrent | number : '1.2-2'}}</h1>
</div>
</div>
</div>
</div>
</div>
I would like the "70.10" string to be aligned vertically and horizontally
Thank you for your help

Using an h1 here for styling purposes is not advised as you'll get issues with accessibility understanding the DOM structure of the page.
You'll want to put the text straight into the div.card-text element. Then create a set of styles that reflects the styling you want for the text, and in this case I've setup a new class so I can easily reuse this elsewhere.
<div class="clr-row">
<div class="clr-col-2">
<div class="card">
<div class="card-header">This month credits used</div>
<div class="card-block">
<div class="card-text numeric-card-text" *ngIf="credits.length > 0">
{{creditsCurrent | number : '1.2-2'}}
</div>
</div>
</div>
</div>
</div>
.numeric-card-text {
text-align: center;
font-size: 2rem;
padding: 1rem;
font-weight: 400;
}

Related

Display flex and any other HTML tag

Suppose this very simple case:
.header-top .custom-html {
display: flex;
align-items: center;
}
<div class="header-top header-has-center-sm">
<div class="header-row container-fluid">
<div class="header-col header-left hidden-for-sm">
<div class="custom-html"><i class="porto-icon-shipping me-2" style="font-size: 2em; vertical-align: middle;"></i>Shipping to all states, <span style="font-weight: bold;">FREE</span> shipping to orders above $50</div>
</div>
<div class="header-col visible-for-sm header-center">
<div class="custom-html"> </div>
</div>
<div class="header-col header-right hidden-for-sm">
<div class="custom-html"><i class="Simple-Line-Icons-badge me-2" style="font-size: 2em; vertical-align: middle;"></i>All our products are <b>GENUINE</b></div>
</div>
</div>
</div>
As you can see, the content of the <b> tag gets next to the surrounding words, as if there is no whitespace around it.
Can someone explain why this is happening and how to remedy it? It's the first time I notice this happening...
Basically, I set the content's display to flex, as I need to vertically align to the middle the text. But this side-effect was totally unexpected...
The issue is your text grouping. I know it sounds strange but text wrapped in div is not really grouped. You would need to wrap it in a <span> or <p> tag. I have used a <span> just to let the browser know that this text belongs together. You can use a <p> tag which obviously comes with more preset styles like margins on the top and bottom.
.header-top .custom-html {
display: flex;
align-items: center;
}
<div class="header-top header-has-center-sm">
<div class="header-row container-fluid">
<div class="header-col header-left hidden-for-sm">
<div class="custom-html"><span><i class="porto-icon-shipping me-2" style="font-size: 2em; vertical-align: middle;"></i>Shipping to all states, <span style="font-weight: bold;">FREE</span> shipping to orders above $50</span>
</div>
</div>
<div class="header-col visible-for-sm header-center">
<div class="custom-html"> </div>
</div>
<div class="header-col header-right hidden-for-sm">
<div class="custom-html"><span><i class="Simple-Line-Icons-badge me-2" style="font-size: 2em; vertical-align: middle;"></i>All our products are <b>GENUINE</b></span></div>
</div>
</div>
</div>

Add Bootstrap panel with border and centralized text

I'm trying to create two panels in bootstrap with centralized text and different fonts in the text. Like the image below
My code:
<div class="row">
<div class="col-lg-6">
<div class="panel panel-default text-center">
<p>
Collected This Quarter <br>
<b>$8084</b>
</p>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-default text-center">
<p>
Average Property Income YTD <br>
<b>$16,985</b>
</h4>
</div>
</div>
</div>
However, my output is:
How can I have the "shadow" outside the panels and the text inside in similar font to the image above?
Thanks you
I also used to face this problem. So, here is the workaround.
Add the top-level child divs and give them padding (like p-1). This is their only job.
Within each top-level div, add your cell's main content, and style them however you want.
This is the code
<div class="parent row">
<div class="col-lg-6 p-1">
<div class="shadow-sm text-center child">
<p class="p-0 m-0">
Collected This Quarter <br>
<b>$8084</b>
</p>
</div>
</div>
<div class="col-lg-6 p-1">
<div class="shadow-sm text-center child">
<p class="p-0 m-0">
Average Property Income YTD <br>
<b>$16,985</b>
</h4>
</div>
</div>
</div>
Normally I reset padding and margins for .row and .col classes
<style>
.row, .col-lg-6 {
padding: 0;
margin:0;
}
.child {
background-color: white;
}
.parent {
background-color: #F3F4F5;
}
</style>
The result is like this
NOTE: I've used bg-dark and bg-light classes for showing the background colors of parent and child divs. You can give them whichever color you want.
Check out this, used .panel-body wrapper
https://jsfiddle.net/420gwtLz/7/
I will suggest using the latest version of Bootstrap, you will get utility classes for shadow and spacing.

can't make div items to take the full length of it

im trying to postion items to be in the center of the div but it doesn't work
this is a picture for desired output
i don't know why the div items are going to left and the input text don't take the full length of the div
im also trying to add space between the text and the gear icon of the orange buttons
and this is my code :
<af:dialog contentWidth="400" type="none" id="aaa" modal="true">
<div class="row">
<div class="col-md-8 sm-b-b">
<div class="sm-padding-5">
<af:inputText inlineStyle="display: inline-block;width:100%" value="sohoooooooooooooooooo"
simple="true" id="it1"/>
</div>
</div>
<div class="col-md-4 sm-b-b">
<div class="sm-padding-5">
<af:button inlineStyle="display: inline-block;width:100%" text="Search" id="b1"></af:button>
</div>
</div>
</div>
<af:forEach var="node" items="#{bindings.ViewObj11.collectionModel}">
<div class="row">
<div class="col-md-12 sm-b-b">
<div class="sm-padding-5">
<af:link text="#{bindings.Value1.inputValue}" styleClass="btn btn-primary white" id="ot1">
<span aria-hidden="true" class="fa fa-gear"></span>
</af:link>
</div>
</div>
</div>
</af:forEach>
Try this Style in your style sheet
.sm-b-b{
margin: 0 auto;
text-align: center;
width: 100%;
}

Spacing / gap between two col-sm-6 inside an row and align it with the rest of the page

I'm trying to make some space / gap between 2x col-sm-6 inside an row. Have tried some methods from earlier posts here from Stack Overflow, but none seem to make the right result.
What I have tried:
<div class="row">
<div class="col-sm-6">
<div class="col-md-12 contentpage3">
</div>
</div>
<div class="col-sm-6">
<div class="col-md-12 contentpage3">
</div>
</div>
</div>
Well... this creates the right spacing, but then the left and right sides are not allign with the rest of the page content. To help you guys understand what I'm trying to explain, here is a picture.
Here you can see that the upper white content, the width is what I'm trying to keep for all the elements inside the page. I know its because the extra div I added, because the following code is producing the upper white content box you see in the picture, but then there is no spacing. Have also tried with col-md-5 and an offset of 2 but this creates too much spacing.
<div class="row">
<div class="col-sm-6 contentpage3">
</div>
<div class="col-sm-6 contentpage3">
</div>
</div>
What am I doing wrong?
You can do something like this.
All .col-* elements should be inside row elements.
All .col-* elements should contain content, not be content.
.example {
padding-bottom: 15px;
background: #ccc;
}
.example > .row > div {
margin-top: 15px;
}
.example .inside {
height: 50px;
background: #fff;
border: 1px solid #eee;
}
<div class="container-fluid example">
<div class="row">
<div class="col-xs-12">
<div class="inside"></div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="inside"></div>
</div>
<div class="col-xs-6">
<div class="inside"></div>
</div>
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

Reduce spacing between rows

I am using Bootstrap grid system. The spacing between rows is too large.
How can I reduce it?
<div class="row">
<div class="col-md-6">
<h1 id="Heading"> Heading </h1>
<div class="row" style="margin-left:6px;">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span </span> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span </span> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span </span> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span </span> </div>
</div>
</div>
</div>
</div>
</div>
<div>
There are 2 quick solutions possible for this:
Edit bootstrap core css/sass which will be a bad idea as it will affect core functionality of page scaffolding.
Write a separate class and add it in your div for ex:
.row-bottom-margin { margin-bottom:20px; }
and you can use it as
<div class="row row-bottom-margin">
Option 1 is not suggested until unless you are really looking for this change to be applied at all the relevant places and do consider your future designs.
Hope this helps!
Using Bootstrap 4 now you no more need to use any CSS for this as it has utility classes for this purpose.
By default, row elements expands in related to their childs. So your problem is not in .row class but in #rect
On rect element you have a line-height of 1.4 by default bootstrap css. Make it a class rather than id.
You can reduce it to 1.2 for your case...
Do it on a separate css file and overwrite it. That would be a better design for you.
.rect {
line-height: 1.2; // overwrite it on a different css if you prefer
}
In twitter bootstap there is a default margin-bottom:15px property set between rows of the grid system.You can remove this property or overwrite the margin property
<div class= "row marginRow"></div>
Your Css
.marginRow{
margin-bottom:0px !important;
}
or just remove any margin present using
.marginRow{
margin:0px !important;
}

Resources