I am trying to use bootstrap to align my h3 headings with my h5 so that they are in line with each other.
EDIT
I am trying to use the already available bootstrap and avoid changing the css unless absolutely necessary.
Here is a screen to demonstrate what i mean.
E.g. First name should line up with address 1, last name with address 2 etc.
here is the code I have.
<div class="row ">
<div class="col-md-4 ">
<h3>First Name</h3>
<h3>Last Name</h3>
<h3>Week.</h3>
<h3>Code.</h3>
</div>
<div class="col-md-4 ">
<h5>Address 1</h5>
<h5>Address 2</h5>
<h5>Address 3</h5>
<h5>Country</h5>
</div>
</div>
That's not what headers are for. (semantically incorrect, search engines won't like this)
I suggest to simply use a table for this (it IS tabular data) and use different CSS rules for td:first-child and td:nth-child(2) in order to get the different font sizes.
.x {
width: 100%;
}
.x td {
padding: 10px;
font-family: sans-serif;
font-weight: light;
}
.x td:first-child {
font-size: 24px;
width: 60%;
}
.x td:nth-child(2) {
font-size: 16px;
width: 40%;
}
<table class="x">
<tr>
<td>First Name</td>
<td>Address 1</td>
</tr>
<tr>
<td>Last Name</td>
<td>Address 2</td>
</tr>
<tr>
<td>Week.</td>
<td>Address 3</td>
</tr>
<tr>
<td>Code.</td>
<td>Country</td>
</tr>
</table>
Better not to mess with the h3/h5 heights, and use multiple rows instead. E.g. what if one of the texts becomes so long that it wraps? Then you can say bye-bye to your aligned layout. That will never happen if you use multple rows:
<div class="row">
<div class="col-md-4">
<h3>First Name</h3>
</div>
<div class="col-md-4">
<h5>Address 1</h5>
</div>
</div>
<div class="row">
<div class="col-md-4">
<h3>Last Name</h3>
</div>
<div class="col-md-4">
<h5>Address 2</h5>
</div>
</div>
<div class="row">
<div class="col-md-4">
<h3>Week.</h3>
</div>
<div class="col-md-4">
<h5>Address 3</h5>
</div>
</div>
<div class="row">
<div class="col-md-4">
<h3>Code.</h3>
</div>
<div class="col-md-4">
<h5>Country</h5>
</div>
</div>
Apart from all this: I agree with the remarks by others that you shouldn't be using h3/h5 in the first place. Headers are intended to define relations between logical units of text, so <h5> is the header of a sub-sub section of text inside a chapter of text that is headed by a <h3> tag.
set same line-heigt, margins, and padding for h3&h5 in css styles
Related
this is what i have:
Im using Angular and Bootstrap. Now i want to make the table header relative positioned to the text inside the container below.
I tried using a html table but sadly you cant make tables like i showed in the picture above with html tables. Currently i use bootstrap columns to align the header and the content inside the widget. Does someone know how i can like "link" the columns inside the widget with the header columns? So if for example the name column is very long, the image header gets moved to the right, aligned with the image column inside the widget.
This is my current code:
widget.component.html
<div class="widget d-flex">
<div class="row">
<div class="col d-flex text-center">
<div class="iconWrapper"></div>
<div class="textWrapper my-auto">
<p class="headingText">mongodb-1</p>
<div class="state d-flex">
<span class="stateText mx-auto">RUNNING</span>
</div>
</div>
<span class="imageText my-auto">
mongodb:latest
</span>
<span class="portText my-auto">
127.0.0.1:9090->80/tcp
</span>
</div>
</div>
</div>
containers.component.html
<div class="col-5">
<div class="row justify-content-left">
<div class="col-5">
<p class="name text-start">Name</p>
</div>
<div class="col-4">
<p class="image text-start">Image</p>
</div>
<div class="col-1">
<p class="port text-start">Ports</p>
</div>
</div>
<ng-container *ngIf="this.containerService.getContainers() != null">
<div class="row justify-content-left h-10 rowTop" *ngFor="let container of this.containerService.getContainers()">
<app-widget></app-widget>
</div>
</ng-container>
</div>
This is exactly why you must use either tables or grids. I don't see any reason why you can't replicate the above example using tables?
Here is the code for a sample table I created to replicate your example - I also added the whole component inside an overflown container in case it runs out of space:
HTML:
<div class="overflown-container">
<table>
<thead>
<tr>
<td> </td>
<td>Name</td>
<td>Image</td>
<td>Ports</td>
</tr>
</thead>
<tbody>
<tr>
<td><img src="https://placekitten.com/48/48"></td>
<td>mongo-db-1<br><span class="label">RUNNING</span></td>
<td>mongodb:latest</td>
<td>127.0.0.1:9090->80/tcp</td>
</tr>
</tbody>
</table>
</div>
CSS:
.overflown-container {
overflow-x: auto;
}
table {
border-spacing: 0;
border-padding: 0;
}
table img {
border-radius: 5px;
}
table tbody tr td {
padding: 10px;
background: tomato;
}
table tbody tr td:first-child {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
table tbody tr td:last-child {
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.label {
background: green;
color: #fff;
font-size: 12px;
padding: 5px;
border-radius: 5px;
}
Below is a working sample of more or less what you are after, adjust to your actual design:
https://jsfiddle.net/7cybnut5/2/
I've got the following structure:
.pinyined-char {
display: inline-block;
}
.unpinyined-char {
display: inline-block;
}
.pinyin {
font-size: 10 px;
text-align: center;
}
.char {
text-align: center;
}
<div class="pinyined-char">
<div class="pinyin">duō</div>
<div class="char">多</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">,</div>
</div>
<div class="pinyined-char">
<div class="pinyin">qǐng</div>
<div class="char">請</div>
</div>
<div class="pinyined-char">
<div class="pinyin">fǎng wèn</div>
<div class="char">訪問</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">http://www.Caringo.com 。
</div>
</div>
<div class="pinyined-char">
<div class="pinyin">àn zhào</div>
<div class="char">按照</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">Caringo LinkedIn: https : //www.linkedin.com/company/caringo-inc- Twitter: https : //twitter.com/CaringoStorage
</div>
</div>
<div class="pinyined-char">
<div class="pinyin">guān yú</div>
<div class="char">關於</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">Caringo Caringo</div>
</div>
<div class="pinyined-char">
<div class="pinyin">shè bèi</div>
<div class="char">設備</div>
</div>
<div class="pinyined-char">
<div class="pinyin">hé</div>
<div class="char">咊</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">Caringo LinkedIn</div>
</div>
</div>
Ultimately, I want all of the .pinyined-char and .unpinyined-char .char divs to line up next to each other, with the .pinyin divs on top
I can sorta get this working by putting display: inline-block on .pinyined-char and .unpinyined-char, but I find that it doesn't wrap well
How do I make this wrap properly and put everything inline, while keeping pinyin on top of the respective characters in .char?
Example:
NOTE: I have edited the example to be much closer to what I am experiencing. The problem I am trying to solve is between the
àn zhào
按 照
line and the Caringo Linkedin. I would like that Caringo Linkedin to appear on the same line and wrap.
https://jsfiddle.net/70kbtLru/11/
This is specifically what the HTML5 <ruby> element was introduced for. In a <ruby> element you can add ruby annotations with the <rt> tag, while using <rp> for backwards compatibility.
Something like
duō
多
can be rendered by this code:
<ruby>
多 <rp>(</rp><rt>duō</rt><rp>)</rp>
</ruby>
Browsers that don’t support <ruby> will render it like this, depending on the choice of <rp> parentheses:
多 (duō)
Taking your current example of annotated text, the HTML would look something like this:
<ruby>
多 <rp>(</rp><rt>duō</rt><rp>)</rp>
</ruby>
,
<ruby>
請 <rp>(</rp><rt>qǐng</rt><rp>)</rp>
訪 <rp>(</rp><rt>fǎng</rt><rp>)</rp>
問 <rp>(</rp><rt>wèn</rt><rp>)</rp>
</ruby>
https://www.Caringo.com 。
<ruby>
按 <rp>(</rp><rt>àn</rt><rp>)</rp>
照 <rp>(</rp><rt>zhào</rt><rp>)</rp>
</ruby>
Caringo LinkedIn: https://www.linkedin.com/company/caringo-inc- Twitter: https://twitter.com/CaringoStorage
<ruby>
關 <rp>(</rp><rt>guān</rt><rp>)</rp>
於 <rp>(</rp><rt>yú</rt><rp>)</rp>
</ruby>
Caringo Caringo
<ruby>
設 <rp>(</rp><rt>shè</rt><rp>)</rp>
備 <rp>(</rp><rt>bèi</rt><rp>)</rp>
咊 <rp>(</rp><rt>hé</rt><rp>)</rp>
</ruby>
Caringo LinkedIn
How about this?
.pinyined-char, .unpinyined-char {
display: inline-block;
}
.pinyin {
font-size: 10px;
}
.char, .pinyin {
text-align: center;
width: 100%
}
<div>
<div class="pinyined-char">
<div class="pinyin">shè bèi</div>
<div class="char">設備</div>
</div>
<div class="pinyined-char">
<div class="pinyin">hé</div>
<div class="char">咊</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">Caringo LinkedIn</div>
</div>
</div>
<div>
<div class="pinyined-char">
<div class="pinyin">shè bèi</div>
<div class="char">設備</div>
</div>
<div class="pinyined-char">
<div class="pinyin">hé</div>
<div class="char">咊</div>
</div>
<div class="unpinyined-char">
<div class="pinyin"></div>
<div class="char">Caringo LinkedIn</div>
</div>
</div>
Otherwise, here it is with a table.. and each word vertically aligned to each character.
<table>
<tr>
<td>shè</td>
<td>bèi</td>
<td>hé</td>
<td></td>
</tr>
<tr>
<td>設</td>
<td>備</td>
<td>咊</td>
<td>Caringo LinkedIn</td>
</tr>
<tr>
<td>shè</td>
<td>bèi</td>
<td>hé</td>
<td></td>
</tr>
<tr>
<td>設</td>
<td>備</td>
<td>咊</td>
<td>Caringo LinkedIn</td>
</tr>
</table>
This here was with the code exactly like you showed (ie, two different sets of texts / with matching translations)
This snippet can easily be extended to add more text in the table, if needed
#wrapper {
display: flex;
flex-wrap: wrap;
}
td {
text-align: center;
}
.char,span {
text-align: center;
align-self: flex-end;
padding-bottom: .3em;
padding-left: .5em;
}
<div id="wrapper">
<table>
<tr>
<td>duō</td>
</tr>
<tr>
<td>多</td>
</tr>
</table>
<span>,</span>
<table>
<tr>
<td>qǐng</td>
<td>fǎng wèn</td>
</tr>
<tr>
<td>請</td>
<td>訪問</td>
</tr>
</table>
<div class="char">
http://www.Caringo.com
</div>
<table>
<tr>
<td>àn zhào</td>
</tr>
<tr>
<td>按照</td>
</tr>
</table>
<div class="char">
Caringo LinkedIn
Twitter
</div>
<table>
<tr>
<td>guān yú</td>
</tr>
<tr>
<td>關於</td>
</tr>
</table>
<div class="char">Caringo Caringo</div>
<table>
<tr>
<td>shè bèi</td>
<td>hé</td>
</tr>
<tr>
<td>設備</td>
<td>咊</td>
</tr>
</table>
<div class="char">Caringo LinkedIn</div>
</div>
I'm using bulma.css for a layout, but when I give a border to something I've found its overlapping.
Here is the overlap:
The .shop div seems 'as expected'
But the .basket div seems to be creeping up a bit.
Here is a link to a demo
And Html:
<div id="app">
<div class="container">
<div class="shop">
<div class="columns">
<div class="column is-one-quarter product">
<h3 class="title is-4">Cat</h3>
<p>
£<span>2.99</span></p>
<div><button class="button">Add to basket</button></div>
</div>
<div class="column is-one-quarter product">
<h3 class="title is-4">Dog</h3>
<p>
£<span>4.00</span></p>
<div><button class="button">Add to basket</button></div>
</div>
</div>
</div>
<div class="basket">
<h1>Basket</h1>
<table class="table">
<thead>
<tr>
<td>Item</td>
<td>Quantity</td>
<td>Price</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">No items in the basket</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
CSS:
// All of bulma.css
html,body{
height:100%;
padding:20px;
}
.product{
box-sizing:border-box;
border:2px solid #eaeaea;
padding:20px;
}
I think its something to do with ... flexbox? I'm not sure!
In it's latest version try is-gapless along with columns class
The bottom container is creeping up over the top container because of this rule in the Bulma code:
.columns:last-child {
margin-bottom: -.75rem;
}
Just override it. Add this to your code:
.columns:last-child {
margin-bottom: 0 !important;
}
!important may not be necessary. I just added it to ensure that your rule prevails.
There is a gap between elements of an input group, if put into a table.
<link href="https://rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<p>This is fine</p>
<div class="row">
<div class="col-xs-4">
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</div>
</div>
<table>
<tr>
<td>There is a gap between spans in tables</td>
</tr>
<tr>
<td>
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</td>
</tr>
</table>
How can I get rid of this gap?
You could try removing the border-spacing added by the table. Alternatively, you can set the border-collapse to collapse if you prefer the way that looks.
border-spacing is inherited by default in CSS by child elements. input-group is set to display: table which means it inherits the borders-spacing: 2px from the parent table. This means it will be applied to input-group-addons since they are being displayed as table cells.
table .input-group {
border-spacing: 0;
}
<link href="https://rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<p>This is fine</p>
<div class="row">
<div class="col-xs-4">
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</div>
</div>
<table>
<tr>
<td>Previously a gap between elements</td>
</tr>
<tr>
<td>
<div class="input-group">
<div class="input-group-addon">a</div>
<div class="input-group-addon">b</div>
</div>
</td>
</tr>
</table>
I m expecting like this image Link
In the image there 5 images and link to dotted images..
May i know, How to display with using bootstrap classes.
I just confused, can anyone help me to fix this?
Thanks,
Here is the code by using table tag:
<td class="tdbodycontent" id="workDemo">
<div class="wrapper" style="height:340px;">
<table class="tblhomecontent dotted" cellpadding="0" cellspacing="0">
<tbody><tr>
<td colspan="5">
<div class="boxtitle">
How it works</div>
</td>
</tr>
<tr>
<td class="box5col">
<div class="marker_1 center">
</div>
<p class="markerContent">
Sign Up for free</p>
</td>
<td class="box5col">
<div class="marker_2 center">
</div>
<p class="markerContent">
Select the<br>
neighborhoods<br>
you want to follow</p>
</td>
<td class="box5col">
<div class="marker_3 center">
</div>
<p class="markerContent">
Invite friends and<br>
family to join</p>
</td>
<td class="box5col">
<div class="marker_4 center">
</div>
<p class="markerContent">
Receive important<br>
alerts and information<br>
from trusted sources</p>
</td>
<td class="box5col">
<div class="marker_5 center">
</div>
<p class="markerContent">
Share information<br>
with friends<br>
securely</p>
</td>
</tr>
</tbody></table>
</div>
</td>
I need to convert in bootstrap, Here is the image link dotted , step-1 , step-2 , step-3 , step-4 , step-5
This may work for you.
or you need to write a custom media css style to achieve this.
<div class="row">
<div class="col-md-2 col-md-offset-1"><img src="images/sample.jpg"></div>
<div class="col-md-2"><img src="images/sample.jpg"></div>
<div class="col-md-2"><img src="images/sample.jpg"></div>
<div class="col-md-2"><img src="images/sample.jpg"></div>
<div class="col-md-2"><img src="images/sample.jpg"></div>
</div>
Building on top of anu g prem's solution, and adding something for the dotted lines, plus a bit of explanations.
Live example
<div class="container">
<div class="row steps">
<hr class="col-xs-8 col-xs-offset-2" />
<div class="col-xs-2 col-xs-offset-1"><img src="http://s22.postimg.org/pq17qfgwd/step_1.png" class="img-responsive"></div>
<div class="col-xs-2"><img src="http://s22.postimg.org/5u58avzv1/step_2.png" class="img-responsive"></div>
<div class="col-xs-2"><img src="http://s22.postimg.org/58g9es4st/step_3.png" class="img-responsive"></div>
<div class="col-xs-2"><img src="http://s22.postimg.org/576bld2z1/step_4.png" class="img-responsive"></div>
<div class="col-xs-2"><img src="http://s22.postimg.org/g9bejsx1p/step_5.png" class="img-responsive"></div>
</div>
</div>
.steps {
position: relative;
}
.steps hr {
/* Use the 3 lines below to use a dotted line image file as background of the <hr> */
border: none;
background: transparent url('http://s22.postimg.org/53ci53xht/dotted.png') no-repeat center center;
height: 2px;
/* Use the line below instead to style the <hr> with a border */
/*border-top: 1px dashed gray;*/
margin-top: 0;
margin-bottom: 0;
position: absolute;
top: 50%;
}
.steps .img-responsive {
margin: 0 auto;
}
You'll notice I did not use your dotted line, and instead used an <hr>, and styled its border-top with a dashed line. (Edit: but op wants to use the image he provided, see comments.)
To answer your question regarding the number of columns (10 vs Bootstrap grid's 12), you need to understand that you don't always have to fill all the twelve columns. Here, we're using 2 columns per image, plus a first column as offset, and you get your five images, centered, with one offset column on the left, and an empty column on the right, and it's fine!
Note that I used img-responsive class to ensure your images never grow too big, outside of their 2 columns, and that I used xs (meaning "extra small") in the class col-xs-2, which means all device screen sizes will get the five images on the same line (and resized to fit), which might not be want you want for smaller devices...