how to create a custom tooltip using title attribute without jquery - angularjs

I want to create a tooltip as shown in pic. Value in title tag is coming from controller.
This is my table code:
<table border="1" cellpadding="10">
<tbody style="white-space: nowrap;">
<tr ng-repeat="row in rows">
<td style="width: 2%;">
<input type="checkbox"
ng-model="tableSelection[$index]"
style="margin-left: 10px;">
</td>
<td style="font-size: smaller; width: 27%; color: gray; white-space: nowrap;"
ng-repeat="col in input_columns"
droppable="dropable"
drop-fn="drop"
drop-index="$index"
drop-data="col"
title=""
ng-click="openDialog($event,$index)"
tempValue=""><enter data></td>
<td style="font-size: smaller; width: 27%; color: gray; white-space: nowrap;"
ng-repeat="col in output_columns"
droppable="dropable"
drop-fn="dropOutput"
drop-index="$index"
drop-data="col"
title=""
ng-click="openDialogOutputConst($event,$index)"><enter data></td>
</tr>
</tbody>
</table>
Can anyone help me how to provide a tooltip like this.

Something like this?
td {
position: relative;
}
td:hover:before {
content: attr(data-title);
position: absolute;
background-color: yellow;
top: 100%;
width: 200px;
white-space: normal;
word-spacing: 200px;
}
<table border="1" cellpadding="10">
<tbody style="white-space: nowrap;">
<tr ng-repeat="row in rows">
<td style="width: 2%;">
<input type="checkbox" ng-model="tableSelection[$index]" style="margin-left: 10px;">
</td>
<td style="font-size: smaller; width: 27%; color: gray; white-space: nowrap;" ng-repeat="col in input_columns" droppable="dropable" drop-fn="drop" drop-index="$index" drop-data="col" data-title="Idaho Illinois Indiana Iowa Kansas Missouri Nebraska Ohio"
ng-click="openDialog($event,$index)" tempValue=""><enter data></td>
<td style="font-size: smaller; width: 27%; color: gray; white-space: nowrap;" ng-repeat="col in output_columns" droppable="dropable" drop-fn="dropOutput" drop-index="$index" drop-data="col" data-title="Some text here" ng-click="openDialogOutputConst($event,$index)"><enter data></td>
</tr>
</tbody>
</table>

You could work with a :before :afterand do some manual positioning.
Using the :before as the stroke and the :after as the tooltip. You could create something like this.
body {
margin-top: 100px;
}
.item {
position: relative;
display: inline-block;
padding: 20px;
background: #fff;
border: 2px solid crimson;
// the stroke
// and the tooltip
// hide them by default
&:before,
&:after {
content: '';
position: absolute;
display: none;
}
// the stroke
&:before {
width: 100px;
height: 2px;
background: crimson;
right: -100px;
transform-origin: 0 0;
transform: rotate(-20deg);
}
// the tooltip itself
&:after {
content: attr(title);
color: #fff;
top: -30px;
right: -250px;
width: 150px;
padding: 5px;
background: #000;
}
// when hover the item,
// display before and after
&:hover {
&:before,
&:after {
display: inline-block;
}
}
}
https://jsfiddle.net/808443bt/

Related

How to fit a flex container inside a grid container

I am trying to fit in a flex container with margins on both sides inside a grid container, but at the smallest viewport width the flex container leaks out. I have added borders to the respective divs to show where its leaking.
I have also added a demo to show my problem: https://codesandbox.io/s/9z49m3ny0p
If the demo isn't clear, take a look at these screenshots:
As you see from the above screenshots, that the red border stays within the viewport at all times but the blue bordered container spills out.
Home.js
<div id="rightContainer">
<div id="editorContainer">
<Notepad />
</div>
<div id="notesCardContainer">
<NoteCard />
<NoteCard />
</div>
</div>
Home.css
#editorContainer {
display: grid;
width: 100%;
position: relative;
border: 1px solid red;
}
#notesCardContainer {
display: grid;
width: 100%;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
flex-direction: row;
justify-content: space-evenly;
padding-bottom: 60px;
}
And Notepad.js :
<div className="editorInnerContainer">
<div className="editorTop">
<input
type="text"
id="noteTitle"
value="Some Title"
disabled={true}
/>
<div id="tools">
<a href="" title="Edit this note">
<i className="fas fa-pencil-alt" />
</a>
<a href="" title="Delete this note">
<i className="fas fa-trash" />
</a>
<a href="" title="Download this note">
<i className="fas fa-download" />
</a>
<a href="" title="Share this note">
<i className="fas fa-share-square" />
</a>
</div>
</div>
</div>
Snippet from Notepad.css
.editorInnerContainer {
display: flex;
flex-direction: column;
background-color: var(--white-100);
padding: 20px;
margin-left: 20px;
margin-right: 20px;
margin-top: 50px;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.14);
border: 1px solid blue;
}
Take a look at this:
https://codesandbox.io/s/2v0o67w4kn
#noteTitle {
flex: 1;
height: 60px;
font-size: 18px;
line-height: 17px;
font-weight: 700;
border: none;
color: var(--black);
border: 2px solid sandybrown;
/* add width */
width: 100%;
max-width: 100%;
}
If you want to adjust the border issue as well, set the width to 100% - the border sizes added together via calc: https://codesandbox.io/s/l7rk0zop69
#noteTitle {
width: calc(100% - 6px);
max-width: calc(100% - 6px);
}

How to change the color of the first line?

I'm trying to achieve a colored background for my table. I want that when it is on its responsive form, the first lines that are selected in the picture (the lines that start with this word "Caracteristiques") have a specific background color to structure my table, is this possible?
body{font-family:'Varela Round';}
th {
background: #333;
color: white;
font-weight: bold;
}
#media (max-width: 500px) {
.responsive-table-line td:before { content: attr(data-title); }
.responsive-table-line table,
.responsive-table-line thead,
.responsive-table-line tbody,
.responsive-table-line th,
.responsive-table-line td,
.responsive-table-line tr {
display: block;
}
.responsive-table-line thead tr {
display:none;
}
.responsive-table-line td {
position: relative;
border: 0px solid transparent;
padding-left: 50% !important;
white-space: normal;
text-align:right;
}
.responsive-table-line td:before {
position: absolute;
top: 0px;
left: 0px;
width: 45%;
padding-right: 15px;
height:100%;
white-space: nowrap;
text-overflow: ellipsis !important;
overflow:hidden !important;
text-align:left;
background-color:#f8f8f8;
padding:2px;
}
}
<div class="responsive-table-line" style="margin:0px auto;max-width:700px;">
<table class="table table-bordered table-condensed table-body-center" >
<thead>
<tr>
<th class="data-title">Caractéristiques</th>
<th>Quantité </th>
<th>Part CAC 40</th>
<th>Part Filiales +1000K€</th>
<th>Contacts IT</th>
</tr>
</thead>
<tbody>
<tr>
<td data-title="Caractéristiques">Société</td>
<td data-title="Quantité">230</td>
<td data-title="Part CAC 40">40</td>
<td data-title="Filiales +1000K€">190</td>
</tr>
<tr>
<td data-title="Caractéristiques">Contacts</td>
<td data-title="Quantité">16 700</td>
<td data-title="Part CAC 40">10 000</td>
<td data-title="Filiales +1000K€">6 700</td>
<td data-title="Contacts IT">21%</td>
</tr>
<tr>
<td data-title="Caractéristiques">Email nominatif</td>
<td data-title="Quantité">16 700</td>
</tr>
<tr>
<td data-title="Caractéristiques">Opt-out</td>
<td data-title="Quantité">3%</td>
</tr>
<tr>
<td data-title="Caractéristiques">Lignes directes/mobiles</td>
<td data-title="Quantité">35%</td>
</tr>
<tr>
<td data-title="Caractéristiques">% Contact IT</td>
<td data-title="Quantité">21%</td>
</tr>
</tbody>
</table>
</div>
You can do what you are trying to do with :pseudo, I have added just two rules
body {
font-family: 'Varela Round';
}
th {
background: #333;
color: white;
font-weight: bold;
}
#media (max-width: 500px) {
/**** Added CSS Rules ****/
tr:nth-child(1n+1) td:first-child {
background: red;
}
tr:nth-child(1n+1) td:first-child:before {
background: red;
}
/**** End of Added CSS Rules ****/
.responsive-table-line td:before {
content: attr(data-title);
}
.responsive-table-line table,
.responsive-table-line thead,
.responsive-table-line tbody,
.responsive-table-line th,
.responsive-table-line td,
.responsive-table-line tr {
display: block;
}
.responsive-table-line thead tr {
display: none;
}
.responsive-table-line td {
position: relative;
border: 0px solid transparent;
padding-left: 50% !important;
white-space: normal;
text-align: right;
}
.responsive-table-line td:before {
position: absolute;
top: 0px;
left: 0px;
width: 45%;
padding-right: 15px;
height: 100%;
white-space: nowrap;
text-overflow: ellipsis !important;
overflow: hidden !important;
text-align: left;
background-color: #f8f8f8;
padding: 2px;
}
}
<div class="responsive-table-line" style="margin:0px auto;max-width:700px;">
<table class="table table-bordered table-condensed table-body-center" >
<thead>
<tr>
<th class="data-title">Caractéristiques</th>
<th>Quantité </th>
<th>Part CAC 40</th>
<th>Part Filiales +1000K€</th>
<th>Contacts IT</th>
</tr>
</thead>
<tbody>
<tr>
<td data-title="Caractéristiques">Société</td>
<td data-title="Quantité">230</td>
<td data-title="Part CAC 40">40</td>
<td data-title="Filiales +1000K€">190</td>
</tr>
<tr>
<td data-title="Caractéristiques">Contacts</td>
<td data-title="Quantité">16 700</td>
<td data-title="Part CAC 40">10 000</td>
<td data-title="Filiales +1000K€">6 700</td>
<td data-title="Contacts IT">21%</td>
</tr>
<tr>
<td data-title="Caractéristiques">Email nominatif</td>
<td data-title="Quantité">16 700</td>
</tr>
<tr>
<td data-title="Caractéristiques">Opt-out</td>
<td data-title="Quantité">3%</td>
</tr>
<tr>
<td data-title="Caractéristiques">Lignes directes/mobiles</td>
<td data-title="Quantité">35%</td>
</tr>
<tr>
<td data-title="Caractéristiques">% Contact IT</td>
<td data-title="Quantité">21%</td>
</tr>
</tbody>
</table>
</div>
Hope this helps :)

Align center Circles CSS (number of circles are handled by AngularJS)

Below how it looks :
Below What I would like to have :
or if getNumber return more for example
(so basicaly the circle are always align center whatever number my getNumber return)
Below the AngularJS code :
<div class="w3-container">
<span ng-repeat="i in getNumber(data.numberOfState) track by $index" style="margin-right:10%;">
<div id="advanced" class="circle" ></div>
</span>
<div id="barre"></div>
</div>
Below the CSS code :
.circle {
border-radius: 50%;
width: 18px;
height: 18px;
background: RoyalBlue;
display: inline-block;
}
#barre{
width: 100%;
height: 3px;
background: RoyalBlue;
margin-top: -17px;
}
#advanced {
width: 18px;
height: 18px;
/* TODO */
}
.circleActive {
border-radius: 40%;
width: 15px;
height: 15px;
background: RoyalBlue;
display: inline-block;
}
How to align center the circle on the bar ?
right: 50%;
left: 50%;
position: absolute;
With this it works but since my circle are iterate by my javascript there are showing at the same coordinated, so I can see only one.
Add text-align:center; to .circle parent
.w3-container {text-align:center;}
Here's small snippet for you
.parent {text-align:center;}
.child {height:14px; width:14px; background:royalblue; display:inline-block;}
<div class="parent">
<span class="child"></span>
</div>
<div class="parent">
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
</div>
<div class="parent">
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
<span class="child"></span>
</div>
This is easy if you are using a flexbox - you only need to give:
display:flex;
width:100%;
justify-content: space-around;
Some suggestions though:
Using id inside an ng-repeat is wrong, as you will then get multiple ids which is invalid.
barre is omitted and using an after psuedo element just for more markup readability.
The line (using after) is absolutely positioned with respect to the flexbox
See demo below:
.circle {
border-radius: 50%;
width: 18px;
height: 18px;
background: RoyalBlue;
display: inline-block;
}
.wrapper {
display:flex;
width:100%;
justify-content: space-around;
position:relative;
}
.wrapper:after {
position:absolute;
content:'';
display:block;
width: 100%;
top:7px;
height: 3px;
background: RoyalBlue;
}
.advanced {
width: 18px;
height: 18px;
}
.circleActive {
border-radius: 40%;
width: 15px;
height: 15px;
background: RoyalBlue;
display: inline-block;
}
<div class="w3-container">
<div class="wrapper">
<div class="circle advanced" ></div>
<div class="circle advanced circleActive" ></div>
<div class="circle advanced" ></div>
</div>
</div>
You can use display: flex; for container. To center elements add justify-content: center;.
.line {
display: flex;
justify-content: center;
margin: 50px;
border-top: 2px solid blue;
}
.circle {
flex: 0 0 auto;
width: 20px;
height: 20px;
margin: 0 20px;
background-color: blue;
border-radius: 50%;
transform: translateY(-50%);
}
<div class="line">
<div class="circle"></div>
</div>
<div class="line">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
<div class="line">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>

Angularjs - Unable to apply ng-style to img tag (using ng-repeat)

I'm using Angularjs in order to display some images in the DOM, and apply some style to them (dim the background). It seems I am unable to apply ng-style to the img tag. What is the reason to that?
Fiddle here.
HTML:
<div ng-controller="MyController">
<div class="row">
<div class="col-md-4 col-lg-4 col-sm-12 postCon" ng-repeat="post in posts">
<div class="rel">
<img src="{{post.link}}" alt="..." class="img-thumbnail" ng-click="test()" ng-style="{'background':'linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('+post.link+')','background-size': 'cover'}">
<li class="del">button</li><li class="getLink">get link</li>
</div>
</div>
</div>
</div>
CSS:
.del{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
left: 0;
bottom: 0;
}
.getLink{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
right: 0;
bottom: 0;
}
.rel{
position: relative;
height: auto;
width: auto;
display: inline-block;
}
Please try the following:
HTML:
<div ng-controller="MyController">
<div class="row">
<div class="col-md-4 col-lg-4 col-sm-12 postCon" ng-repeat="post in posts">
<div class="rel">
<div class="cover-img">
<img src="{{post.link}}" alt="..." class="img-thumbnail" ng-click="test()" style="background:linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));background-image: url('{{post.link}}');background-size: cover">
</div>
<li class="del">button</li><li class="getLink">get link</li>
</div>
</div>
CSS:
.del{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
left: 0;
bottom: 0;
}
.getLink{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
right: 0;
bottom: 0;
}
.rel{
position: relative;
height: auto;
width: auto;
display: inline-block;
}
.cover-img{
position:relative;
}
.cover-img:before{
content:'';
background: rgba(69, 71, 94, 0.53);
position:absolute;
left:0;
right:0;
bottom:0;
top:0;
width:100%;
height:100%;
}
I don't think that how ng-style works. You can see example here and here.
Try this:
In html:
<img ng-style="yourStyle">
In controller:
$scope.yourStyle =
{
'background': 'linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))',
'background-size': 'cover'
}
Hope this help.

google app engine local server does not run on chrome/firefox

When I create an application in google app engine and open the application (http:localhost:8080) in safari it works fine. But when I open in chrome or fire fox it does not run (http:localhost:8080) and gives the following page.
<HTML><HEAD><TITLE>Error Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<STYLE id=L_10061_1>A {
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #005a80; FONT-FAMILY: tahoma
}
A:hover {
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #0d3372; FONT-FAMILY: tahoma
}
TD {
FONT-SIZE: 8pt; FONT-FAMILY: tahoma
}
TD.titleBorder {
BORDER-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 0px solid; COLOR: #955319; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-ALIGN: left
}
TD.titleBorderx {
BORDER-RIGHT: #955319 0px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 1px solid; COLOR: #978c79; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-ALIGN: left
}
.TitleDescription {
FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: tahoma
}
SPAN.explain {
FONT-WEIGHT: normal; FONT-SIZE: 10pt; COLOR: #934225
}
SPAN.TryThings {
FONT-WEIGHT: normal; FONT-SIZE: 10pt; COLOR: #934225
}
.TryList {
MARGIN-TOP: 5px; FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: tahoma
}
.X {
BORDER-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; FONT-WEIGHT: normal; FONT-SIZE: 12pt; BORDER-LEFT: #955319 1px solid; COLOR: #7b3807; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #d1c2b4
}
.adminList {
MARGIN-TOP: 2px
}
</STYLE>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY bgColor=#f3f3ed>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD class=titleBorderx width=30>
<TABLE height=25 cellSpacing=2 cellPadding=0 width=25 bgColor=black>
<TBODY>
<TR>
<TD id=L_10061_x class=x valign=middle align=center>X</TD>
</TR>
</TBODY>
</TABLE>
</TD>
<TD class=titleBorder id=L_10061_2>Network Access Message:<SPAN class=TitleDescription> The page cannot be displayed</SPAN> </TD>
</TR>
</TBODY>
</TABLE>
<TABLE id=spacer>
<TBODY>
<TR>
<TD height=10></TD></TR></TBODY></TABLE>
<TABLE width=400>
<TBODY>
<TR>
<TD noWrap width=25></TD>
<TD width=400><SPAN class=explain><ID id=L_10061_3><B>Explanation:</B></ID></SPAN><ID id=L_10061_4> The Web server refused the connection. </ID><BR><BR>
<B><SPAN class=tryThings><ID id=L_10061_5><B>Try the following:</B></ID></SPAN></B>
<UL class=TryList>
<LI id=L_10061_6><B>Refresh page:</B> Search for the page again by clicking the Refresh button. The timeout could have occurred due to Internet congestion.
<LI id=L_10061_7><B>Check spelling:</B> Check that the Web page address is spelled correctly. The address may have been mistyped.
<LI id=L_10061_8><B>Access from a link:</B> If there is a link to the page you are looking for, try accessing the page from that link.
<LI id=L_10061_9><B>Contact website:</B> You may want to contact the website administrator to make sure the Web page still exists. You can do this by using the e-mail address or phone number listed on the website home page.
</UL>
<ID id=L_10061_10>If you are still not able to view the requested page, try contacting your administrator or Helpdesk.</ID> <BR><BR>
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE id=spacer><TBODY><TR><TD height=15></TD></TR></TBODY></TABLE>
<TABLE width=400>
<TBODY>
<TR>
<TD noWrap width=25></TD>
<TD width=400 id=L_10061_11><B>Technical Information (for support personnel)</B>
<UL class=adminList>
<LI id=L_10061_12>Error Code 10061: Connection refused
<LI id=L_10061_13>Background: The server you are attempting to access has refused the connection with the gateway. This usually results from trying to connect to a service that is inactive on the server.
<LI id=L_10061_14>Date: 11/8/2012 1:19:34 PM [GMT]
<LI id=L_10061_15>Server: NBS-TMGPTCL.Cdocs.local
<LI id=L_10061_16>Source: Remote server
</UL>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
It says you are trying to connect to :
NBS-TMGPTCL.Cdocs.local
and not
http:localhost:8080
in any case, use
http//:localhost:8080

Resources