Increasing scroll height when a tooltip appear - html

I have a table and when hover on certain data of a table column i'm displaying a tool tip. Following image shows it. The issue is when hovering the bottom records, the height of the table won't increase to make room to the tool tip.
The following image shows when hovering data of the top of part of the table. There is no issue with this.
But when hovering bottom part of the table , the position of the tool tip will become incorrect as shown in the following figure (Here i have hovered the last record of the table)
I tried giving much higher hight for the table manually. Then i can get the expected behaviour
I do not want to give the table height manually , i want it to increase height automatically. How can i achieve this target
Table code is as follows
<Table responsive striped borderless hover>
<thead>
<tr id="table_col_names">
<th className="label_type2 pl-lg-5 pl-xs-2 pb-4">Allowed Stations</th>
</tr>
</thead>
<tbody>
{consumers.consumerData && consumers.consumerData.map((item, key) => {
return (
<tr key={key}>
<td className="cell_style pl-lg-5 pl-xs-2">
<OverlayTrigger
placement='bottom'
overlay={
<Tooltip bsPrefix="consumer_tooltip">
{Object.values(this.groupData(item.allowedChargingStations)).map((evc,key) => {
return (
<div>
<p>{evc.groupName}</p>
{evc.stations.map((evcStation, key) => {
return (
<p className="ml-3">
<li>{evcStation.name}</li>
</p>
)
})}
</div>
)
})}
</Tooltip>
}
>
<label className="cp">{item.allowedChargingStations.length} stations</label>
</OverlayTrigger>
</td>
</tr>
)
})}
</tbody>
</Table>
i have used react bootstrap component OverlayTrigger and Tooltip for the tool tip.
tool tip css
.consumer_tooltip{
background: rgba(24, 68, 119, 0.5);
backdrop-filter: blur(10.8731px);
border-radius: 4px;
font-size: 14px;
width: 160px;
padding-left: 10px !important;
padding-top: 20px !important;
font-weight: 600;
margin-left: 64px;
margin-top: 10px;
pointer-events: none;
}
.consumer_tooltip:before{
content: ' ';
height: 0;
position: absolute;
width: 0;
left: 18px;
top:-20px;
border: 10px solid transparent;
border-bottom-color: rgba(24, 68, 119, 0.5);
}

Related

Place down arrow inside of input that's inside of a table

I have multiple tables across my application. (plain html, css etc, no framework except jQuery)
In some of the td's inside of those tables i have input fields. In some inputs i want to place a downwards pointing arrow, so that the user knows they can click on it to get a custom made dropdown list.
For a while now i've been using something in the line of the example shown below.
So, the user needs to see an input field inside of which on the right side there is a downwards facing arrow.
Also, the text that the user fills in the input field must not go underneath the arrow.
The issue is that the arrow has a fixed width of 20px and a height of 20px, but the input field needs to be as wide as the width of the td minus the width of the arrow (20 px). Setting the input's width to a percentage doesn't work because when the td varies in size, there will be a blank space in between the input and arrow.
CSS:
.col1{
width: 300px;
background-color: yellow;
}
.col2{
width:300px;
background-color: lightgrey
}
.col1 input{
width: 100%;
}
.ArrowBox {
position: relative;
right: 0px;
width: 20px;
height: 20px;
display: inline-block;
background-color: red;
}
.ArrowIcon {
position: relative;
top: -3px;
left: 4px;
width: 10px;
height: 10px;
border: solid white;
border-width: 0 1px 1px 0;
display: inline-block;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
HTML:
<table>
<tr>
<td class="col1">
<input type="text" value="" class="input1">
<i class="ArrowDownBox">
<i class="InputArrowDownIcon"></i>
</i>
</td>
<td class="col2">Line 1, Column 2</td>
</tr>
<tr>
<td class="col1">
<input type="text" value="" class="input2">
<i class="ArrowDownBox">
<i class="InputArrowDownIcon"></i>
</i>
</td>
<td class="col2">Line 2, Column 2</td>
</tr>
</table>
I've put a simple example in a fiddle here:
https://jsfiddle.net/j6ocL702/
The colors used are for example purposes.
Can anyone help me with this? i'm at a loss and google isn't my friend with this atm...
Try giving the input padding-right: 20px; that will stop users typing under the arrow if you position the input relative and the down arrow absolute with right: 0
You'll probably have to fiddle around to make sure default margin or padding isn't being picked up.

How to resize a table when the rows decrease?

I have a table under a searchbar. When I write something inside it, it filters that word with my skills list and the table appears bottom the bar.
Everything works well but not the size of this div because it have an height of 300px so if I have 10 skills is ok, but if the skill are, for example, 2, every td will have a height of 150px.
So I would like to fix this with a max height of 300px and when the rows decrease I want the table to get smaller.
HTML
<div class="container">
<ng-container
*ngIf="searchString.searchString && (searchSkills.getAllSkill() | filterAll : searchString.searchString) as filteredSkills">
<ng-container *ngIf="filteredSkills.length > 0">
<div class="suggerite">
<cdk-virtual-scroll-viewport [itemSize]="10" class="sugtab style-bar modal-bar">
<table class="sugtab">
<tbody>
<tr *cdkVirtualFor="let skill of filteredSkills" class="sugtag">
<td (click)="addToSearch(skill)" class="skill">
{{skill.name}}
</td>
</tr>
</tbody>
</table>
</cdk-virtual-scroll-viewport>
</div>
</ng-container>
</ng-container>
</div>
CSS
.suggerite{
position: relative;
border: 1px solid #064a94;
border-radius: 5px;
background-color: rgba(255,255,255,0.9);
color: #064a94;
z-index: 100;
cursor: pointer;
padding-left: 0 !important;
padding-right: 0 !important;
}
.sugtab{
height: 200px;
width: 100%;
font-family: sans-serif;
}
tr.sugtab {
height: 50px;
}
td.skill{
padding: 3px;
}
I tried to use max height and different things but probably in wrong places.

CSS: Hover adds unwanted extra white space

I am simply trying to create a hover, so it hover over a entire section as seen below:
However, every time i hover over my products.
This happens instead
It adds extra white space to the section below and doesn't cover the section properly.
I have tried..
Changing the line height
Adding a new section/div
padding 0, margin 0
div#cat{
/*line-height: 30%;
height: 50px;*/
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
/*product area rollover/hover*/
div#cat:hover{
background-color: #e86065;
opacity: 0.5;
filter: Alpha(opacity=50);
background-position: 100% 100%;
height: 80%;
}
<div id='cat'>
<table>
<tr>
<td class='full'>
<a name='foodcat$iii' id='prods_nme'>$prod_name</a>
<td>
</td>
<p id='prods_desc'>$prod_desc</p>
</td>
<td class='price'>
<p id='prods_price'>£$prod_price</p>
</td>
<td class='add'>
<a href='Shopping_cart.php?add_item=$prod_id'>+</a>
</td>
</tr>
</table>
</div>
My code is actually a string, which loop information out of a database.
echo("<div id='cat$i' class='cat'>");
echo("<table>");
echo("<tr>");
echo("<td class='full'>");
echo("<a name='foodcat$iii' id='prods_nme'>$prod_name</a>");
echo("<td>");
echo("</td>");
echo("<p id='prods_desc'>$prod_desc</p>");
echo("</td>");
echo("<td class='price'>");
echo("<p id='prods_price'>£$prod_price</p>");
echo("</td>");
echo("<td class='add'>");
echo("<a href='Shopping_cart.php?add_item=$prod_id'>+</a>");
echo("</td>");
echo("</tr>");
echo("</table>");
echo("<br>");
echo("<br>");
echo("<hr id='hr'>");
echo("</div>");
echo("</div>");
echo("</div>");
echo("<br>");
echo("<br>");
$i++;
Your CSS is adding extra height when it changes to hover state. Make sure when you're adding hover styles that you only change the properties you want to - in this case, you don't want to change the height.
You want something like this:
div#cat{
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
/*product area rollover/hover*/
div#cat:hover{
background-color: #e86065;
opacity: 0.5;
filter: Alpha(opacity=50);
background-position: 100% 100%;
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
ArtOfCode has the correct solution for your problem.
However, it is not a good idea to use tables for formatting. You can see the table padding (which I have done all the right things to eliminate) when the cells are given borders. Tables bring with them a number of formatting problems.
I suggest that you use DIVs instead, and learn the three or four things needed to use float:left and/or flexbox.
table{border-collapse:collapse;}
td{border:1px solid #ccc;padding:0;}
div#cat {
/*line-height: 30%;
height: 50px;*/
width: 61%;
margin-left: 39%;
height: 15px;
line-height: 50%
}
/*product area rollover/hover*/
div#cat:hover {
background-color: #e86065;
opacity: 0.5;
filter: Alpha(opacity=50);
background-position: 100% 100%;
height: 80%;
}
<div id='cat'>
<table>
<tr>
<td class='full'>
<a name='foodcat$iii' id='prods_nme'>$prod_name</a>
<p id='prods_desc'>$prod_desc</p>
</td>
<td class='price'>
<p id='prods_price'>£$prod_price</p>
</td>
<td class='add'>
<a href='Shopping_cart.php?add_item=$prod_id'>+</a>
</td>
</tr>
</table>
</div>

Why is my background color not filling all of my table?

I'm having a problem with an image within my table row. For some reason, the background color will not extend and fill the table row in when I have a picture floating to the left.
p.more {
color: rgb(255, 255, 255);
font-family: Arial;
font-size: 18px;
line-height: 140%;
margin: 0px;
text-align: center;
background-color: #cccccc;
}
img.more {
float: left !important;
margin: 0px 15px 15px 0px;
width: 330px;
}
span.more {
line-height: 100%;
text-align: center;
font-size: 18px;
}
span.moreweelove {
color: rgb(255, 255, 255);
}
<table>
<tr>
<td>
<p class="more">
<a href="http://blog.weespring.com/weelove-littlehipsqueaks-knotted-headbands/">
<img class="more" src="http://www.weespring.com/media/weelove_littlehipsqueeks.jpg">
</a>
<br>
<span class="more"><span class="moreweelove"><strong>Modern, Comfy, and Fun Staples</strong></span></span>
</p>
<p class="readmore">
<strong class="subheading">BIG LOVE FOR JUNE & JANUARY</strong>
<br>
<br>
<a href="http://blog.weespring.com/weelove-littlehipsqueaks-knotted-headbands/">
<img src="http://www.weespring.com/media/read-more.png">
</a>
<br>
<br>
</p>
</td>
</tr>
</table>
If want to fullfill an entire row with a background-color, youu should apply a css style to the corresponding < tr > tag.
Since you applied the background color the <p>, only the <p> itself will get colored. If the last line doesn't take up the full width of the container, e.g.
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx
then only the parts with the x will get the background treatment. But if you apply the color to the containing <td>, which surrounds the paragraph, like so:
+------------------------+
|xxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxx |
+------------------------+
Then that final partial line will ALSO be colored, because the entire box of the <td> is colored, not just where the text is.
It's because you're giving style to "p.more" not to the table.
Try giving the background color to the table.

CSS padding overlapping parent element

My HTML:
<table style="width:100%;">
<tbody>
<tr style="cursor:pointer; border-bottom:1px solid #ACACAC; height:60px;">
<td style="text-align:right; vertical-align:middle; padding:10px 10px 10px 0px;">
<span style="color:#F87E20;">Copy</span>
<div style="display:inline; color:#ACACAC;"> | </div>
<span style="color:#F87E20;">Export</span>
<div style="display:inline; color:#ACACAC;"> | </div>
<span style="color:#F87E20;">Delete</span>
</td>
</tr>
</tbody>
</table>
The result:
This is all fine, and is working wonderfully. I want to make some QOL changes, though, and while looking into some of the changes I wanted to make, ran into something that is confusing me quite a bit.
The entire row is clickable, as well as the Copy, Export and Delete spans. This becomes a problem when I try to click on Export, but miss by 2 or 3 pixels, and instead navigate away from this area. I wanted to make the clickable area for the spans bigger, so I gave the a style property like so: padding:10px 0px 10px 0px;
The padding works as intended, enlarging the clickable area around the spans, making it easier to click on them. However, I was expecting the padding to also make the entire row taller, but instead it's as if the spans' padding is just flowing over the padding on the parent.
Here are some images to help explain the situation:
Parent:
And Child:
I don't understand why the child's padding is flowing outside it's container, and I don't want to go on in this direction without understanding what's going on. I was wondering if anyone could please help me understand what's happening here?
Your spans are inline elements. Top and bottom padding is ignored in case of inline elements.
By default, spans are inline, and divs are block. However, you can always override these with display: block; or display: inline;. Block elements (also inline-blocks) have full padding support.
See:
table {
width: 100%;
border-bottom: 1px solid #ACACAC;
}
tr {
cursor: pointer;
height: 60px;
}
td {
text-align: right;
vertical-align: middle;
padding: 10px 10px 10px 0px;
background-color: #e0c000;
}
span {
display: inline-block;
color: #F87E20;
background-color: #f0e000;
}
.padded {
padding: 10px 0 10px;
}
div {
display: inline;
color: #ACACAC;
}
<table>
<tbody>
<tr>
<td>
<span>Copy</span>
<div> | </div>
<span class="padded">Export</span>
<div> | </div>
<span>Delete</span>
</td>
</tr>
</tbody>
</table>
See also this article for more on this.