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/
Related
HTML:
<body class="header">
<div class="container-fluid">
<div class="container d-flex justify-content-center">
<p class="display-3">Password Vault</p>
</div>
</div>
<div class="">
<div class="d-flex justify-content-center align-items-center" style="height: 800px;">
<div class="container border t-box col-5">
<table class="table table-hover t-responsive" >
<tbody>
<tr>
<td>
Lorem ipsum dolor sit amet cons
</td>
<td class="d-flex justify-content-center">
<button type="button" class="btn btn-outline-light btn-sm">View</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
CSS:
.t-transparent{
background-color: transparent;
}
.half-opaque{
opacity: 50%;
}
.nav-t{
height: 70px;
}
.t-box{
border-radius: 10px;
padding: 10px;
}
.t-responsive{
display: block;
max-height: 300px;
overflow-y: scroll;
}
tr{
max-width: 778px;
}
I am using bootstrap 5, the issue is that in bootstrap's table class, there are lines under each row. But in this case the lines are dependent on the tbody, which wraps the content responsively. How do i fix this?
Why are you setting disaply:block to the <table> element?
.t-responsive{
display: block; // remove this
max-height: 300px;
overflow-y: scroll;
}
It is causing table to take full width of the viewport.
If you want <table> to take full width as of parent container then set width:100%, etc.
I have a border box which I am trying to a icon to the far right of the border box using bootstrap 4.3 class float-right but the icon does not move and I can't understand why. I have a child component in which the scss is associated with. I have tried a combination of things but it still does not work. Can someone explain to me what the issue is. Code snippet includes.
Cartitem.html
<div class="container-md" style="height:50%; width:150px;">
<img class="img-fluid" [src]="cartItem.imageUrl" alt="Cart Item">
<div class="text-nowrap" style="font-size:13px; width: 400px">{{cartItem.productName}}
</div>
<div style="font-size:13px"><strong>{{ (cartItem.price) | currency}}</strong></div>
<div class="float-right" style=" clear:both">
<span ><i class="fa-solid fa-trash-can" style="color:#D30169;cursor: pointer;
">
</i></span>
</div>
</div>
cart.html
<div class="container" style="margin-bottom:20px">
<h1 style="text-align: center">Shopping Cart</h1>
<div class="cart-borderBox">
<div class="inside-bB">
div *ngFor="let item of cartItems; let i = index">
<app-cart-item [cartItem]="item"></app-cart-item>
</div>
</div>
</div>
</div>
scss
.cart-borderBox{
box-sizing: border-box;
margin: 0 auto;
/*height: auto;*/
width: 70%;
}
.inside-bB{
border: 3px solid $primary-color;
padding: 50px;
margin:0 auto;
border-radius: 8px;
}
This question already has answers here:
Align child elements of different blocks
(3 answers)
Closed 10 months ago.
We have the following problem:
It is about accommodating three boxes in a row, which should have the same height. In addition, the boxes each contain two parts: an introductory block and a detailed description.
If we now build the whole thing with Bootstrap 4, this is the structure:
/**
* CSS just for visualization
**/
.block-wrap {
background: lightgrey;
height: 50px;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-4 block-wrap">
<div>
Intro text
</div>
<div>
Detais text
</div>
</div>
<div class="col-4 block-wrap">
<div>
Intro text
</div>
<div>
Detais text
</div>
</div>
<div class="col-4 block-wrap">
<div>
Intro text
</div>
<div>
Detais text
</div>
</div>
</div>
We want the blocks (cols) to always have the same height - this means that the tallest block (based on the content) dictates the height of the others. We achieve this by setting the height of all blocks to 100 percent. It will look somewhat like this:
Now it gets tricky. While the blocks should always have the same height among themselves, the detail blocks should always start at the same height, like this:
Any idea how we can achieve this - it is important that the responsive behavior is retained and the blocks also make sense on mobile.
Edit:
I found a simple solution while stumbling across another problem - in hindsight I wonder why I didn't think of that right away, after all I've already worked with it. Thats how it works:
Bootstrap comes with a function to sort the columns. So in the end I just created a row with 6 columns. I then gave them a sorting on the different devices during the break.
I have recreated it again for you to illustrate:
Codepen fullscreen
we can use table to do that. not sure if we can do that flex box or grid without using javascript
.container {
border: 1px solid black;
border-collapse: collapse;
}
.intro {
background:lightblue;
}
.intro div{
background:orange;
}
.details div{
background:lightgreen;
}
.details {
height:100px;
background:lightblue;
}
table td {
width: 1%;
border: 1px solid black;
padding:10px;
vertical-align:top;
}
table td.details{
vertical-align:bottom;
}
.ch-50 {
height: 5em;
}
.ch-75 {
height: 7.5rem;
}
.ch-100 {
height: 10rem;
}
.ch-20 {
height: 2rem;
}
table{width:100%;}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<table class="container">
<tr>
<td class="intro ch-50">
<div class="h-75"></div>
</td>
<td class="intro ch-75">
<div class="h-100"></div>
</td>
<td class="intro ch-100">
<div class="h-50"></div>
</td>
</tr>
<td class="details">
<div class="h-50"></div>
</td>
<td class="details">
<div class="h-75"></div>
</td>
<td class="details">
<div class="h-100"></div>
</td>
<tr>
</tr>
</table>
/**
* CSS just for visualization
**/
.row {
display: flex;
}
.block-wrap {
background: lightgrey;
flex: 1;
border: 1px solid;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.0.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-4 block-wrap">
<div>
Intro text
Intro text
Intro text
</div>
<div>
Detais text
</div>
</div>
<div class="col-4 block-wrap">
<div>
Intro text
</div>
<div>
Detais text
</div>
</div>
<div class="col-4 block-wrap">
<div>
Intro text
Intro text
Intro text
Intro text
</div>
<div>
<p>Detais text</p>
<p>Detais text</p>
<p>Detais text</p>
<p>Detais text</p>
</div>
</div>
</div>
Please check the properties of flex that I have given to block-wrap. You have to give class to Intro Text as well if you want the height of that column to be same as well
I am noob in HTML and CSS. I have content as shown in the image below and I need to wrap in a table again as shown in the picture using red colour. I tried with regular table format but it didn't work. Thanks in advance.
.bubble-info {
margin-top: -12px;
span {
display: inline-block;
border-radius: 50%;
border: 1px solid #0575e6;
&:nth-of-type(1) {
width: 20px;
height: 20px;
}
&:nth-of-type(2) {
width: 40px;
height: 40px;
}
}
}
.color-info {
background-image: linear-gradient(91deg, #8cc6ff, #0575e6);
display: inline-block;
width: 48%;
height: 10px;
border-radius: 10px;
margin-left: 10px;
margin-right: 10px;
margin-top: 15px;
}
<div class="row">
<br>
<div class="col-md-4 bubble-info">
<h5><b>Circle Size:</b></h5>
<small class="help-block">- No. of Students who got it wrong.</small><br/>
Less <span></span>
<span></span> More
</div>
<div class="col-md-5">
<h5><b>Circle Colour:</b></h5>
<small class="help-block">- Proficiency of the students.</small><br/>
Highly Proficient<span class="color-info"></span>Not Aware
</div>
</div>
The Table is based around the tag and inside the <table> tag there are table rows <tr> and inside those rows there are either a table head <th> or table data <td>. Here's an example driven from your code:
<table style="width:100%">
<tr>
<th><h5><b>Circle Size:</b></h5>
<small class="help-block">- No. of Students who got it wrong.</small><br/>
Less <span></span></th>
<th><h5><b>Circle Colour:</b></h5>
<small class="help-block">- Proficiency of the students.</small></th>
</tr>
<tr>
<td>Less <span></span>
<span></span> More</td>
<td>Highly Proficient<span class="color-info"></span>Not Aware</td>
</tr>
</table>
If you used bootstrap, you should use col-6 for 2 column and create a border class for col-6
.borderred{
border: 1px solid red;
}
HTML
<div class="container">
<div class="row">
<div class="col-md-6 borderred">
<h5><b>Circle Size:</b></h5>
<small class="help-block">- No. of Students who got it wrong.</small><br/>
</div>
<div class="col-md-6 borderred">
<h5><b>Circle Colour:</b></h5>
<small class="help-block">- Proficiency of the students.</small><br/>
</div>
</div>
<div class="row">
<div class="col-md-6 borderred">
Less <span></span>
<span></span> More
</div>
<div class="col-md-6 borderred">
Highly Proficient<span class="color-info"></span>Not Aware
</div>
</div>
</div>
.borderred{
border: 1px solid red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 borderred">
<h5><b>Circle Size:</b></h5>
<small class="help-block">- No. of Students who got it wrong.</small><br/>
</div>
<div class="col-md-6 borderred">
<h5><b>Circle Colour:</b></h5>
<small class="help-block">- Proficiency of the students.</small><br/>
</div>
</div>
<div class="row">
<div class="col-md-6 borderred">
Less <span></span>
<span></span> More
</div>
<div class="col-md-6 borderred">
Highly Proficient<span class="color-info"></span>Not Aware
</div>
</div>
</div>
Currently I'm creating a product box with two columns near each other, left one have the product image and right one product description.
The main problem is, I'm trying to make the product description the same height as the image, but after few tries I didn't get close to solve it, because it needs to be responsive. I tried a lot of solutions but still stuck, the closest one was using media queries and apply height to the .product-det but seems like it's not the good way.
I have create a Bootply as a demo.
The blue border must reach the bottom of the wrapper.
HTML
<div class="container">
<div class="col-xs-6">
<div class="col-xs-12 padding-15 margin-b-15 border-default padding-t-0 padding-b-0">
<div class="row">
<div class="col-xs-12">
<div class="row">
<div class="col-xs-4 col-sm-3 nopadding">
<img class="img-responsive" src="http://placehold.it/250x250">
</div>
<div class="col-xs-8 col-sm-9 border-l-default">
<div class="row"> <h4 class="col-xs-10 margin-t-15 text-ellipsis">Article pokeball superpotion lighting boltubertext pokemon pikachu</h4>
<div
class="col-xs-2 padding-t-15"> <span class="pointer pull-right">
<i class="glyphicon glyphicon-remove"></i>
</span>
</div>
<div class="product-det col-xs-12 line-h-35">
<div class="row">
<div class="col-xs-4">ITEMID</div>
<div class="col-xs-4">
<div class="input-group">
<input class="form-control" placeholder="qnt" type="text"> <span class="input-group-btn">
<button class="btn btn-secondary" type="button">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</span>
</div>
</div>
<div class="col-xs-4"><span class="pull-right">3.203 €</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">Right content</div>
</div>
CSS
.text-ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.padding-15 {
padding: 15px;
}
.padding-t-15 {
padding-top: 15px;
}
.margin-b-15 {
margin-bottom: 15px;
}
.border-default{
border: 1px solid #e0e0e0;
}
.padding-t-0 {
padding-top: 0px;
}
.padding-b-0 {
padding-bottom: 0px;
}
.nopadding {
padding: 0;
}
.line-h-35 {
line-height: 35px;
}
.border-l-default {
border-left: 1px solid blue;
}
Try the following:
Html:
<div class="row row-eq-height">
<!--The div columns you want them to be same height should be here-->
</div>
CSS:
/*
Row with equal height columns
*/
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
you can try javascript to do this. because bootstrap col is changing width overtime when you change your devices. I like it, it typeless and you can put the class in your image wrap and your product descript wrap like so:
var st = $('.squarethis').width();
$('.squarethis').css({'height':st+'px'});
$('.sameheight').css({'height':st+'px'});
.wrapper{
background:#ccc;
width:100%;
height:100%;
display:flex;
flex-wrap:wrap;
flex-direction:row;}
.prodImage{
width:30%;
background:red;}
.prodDesc{
width:70%;
background:green;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="prodImage squarethis"></div>
<div class="prodDesc sameheight"></div>
</div>
it will apply on your bootstrap. try to input this.
let me explain what happened:
$('.squarethis').css({'height':st+'px}); it will make your image always square, and it don't care what devices you using.
$('.sameheight').css({'height':st+'px'}); and this thing will make your next bootstrap col following the height of your previous col.
don't forget to input a class in your image wrapper and description wrapper
I'd suggest you to look at bootstrap v4 which comes with awesome features, like flexbox grid.
It does just what you need - example:
#foo{
background-color: aqua;
height: 300px;
}
#bar{
background-color: yellow;
}
<link href="https://cask.scotch.io/bootstrap-4.0-flex.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-6" id="foo">foo</div>
<div class="col-sm-6" id="bar">bar</div>
</div>
</div>
JSFiddle
You can tune this cell (product description) using plain css. Just a little modify class .border-l-default:
.border-l-default {
border-left: 1px solid blue;
height: 100%;
position: absolute;
right: 0;
}
bootply
Try to change the text ellipsis like that, it is a bit rude because i didn't use bootstrap classes, but it works fine to me:
.text-ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 71px;
}
Try to set min-height in different mediaquery
.border-l-default {
border-left: 1px solid blue;
min-height: 135px;