Outline color of title in the input textbox is displaying differently in Google chrome. bottom border line is looking differently.
<input type="text" title="Please fill out this field.">
so i tried with following code:
<span class="pseudo-tooltip-wrapper" data-title="please fill out this field...">
<input type='text' required></span>
sample.css
[data-title]:hover:after {
opacity: 1;
transition: all 0.1s ease 0.5s;
visibility: visible;
}
[data-title]:after {
content: attr(data-title);
background-color: rgb(217, 235, 217);
color: #111;
font-size: 150%;
position: absolute;
padding: 1px 5px 2px 5px;
bottom: -1.6em;
left: 100%;
white-space: nowrap;
/* box-shadow: 1px 1px 3px #222222; */
opacity: 0;
border: 1px solid #111111;
z-index: 99999;
visibility: hidden;
}
[data-title] {
position: relative;
}
.pseudo-tooltip-wrapper {
/*This causes the wrapping element to be the same size as what it contains.*/
display: inline-block;
}
so now it's displaying like below. When i make the field as required the default title bar is displaying.
Instead of this approach can we fix the default title bar border.
Please find the code in stackbliz: https://stackblitz.com/edit/angular-pa2lnu
How to achieve this issue.
You can use angular material Input Form fields, they are simpler, comprehensive and decorative. Lt me know if you find
[This Link] (https://material.angular.io/components/form-field/overview) helpful
You can make a custom tooltip handler. See, I used tooltip and tooltiptext class for displaying custom title.
Stackblitz here
HTML
Hover over me
<br/>
<br/>
<div class="tooltip">
<span class="tooltiptext">Required field</span>
<input title="Please fill" type="text" />
</div>
CSS
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
Related
This is an odd one but I'm sure there's a simple explanation. Can someone explain to me why an event on an input within a div acts differently to an event on input within a label. Please see the following fiddle as an example:
https://jsfiddle.net/anthill/h8v106o7
$('#container .switch input[type="checkbox"]').change(function(e) {
alert($(this).data('message'));
})
body {
font-family: Helvetica, Arial, sans-serif;
padding: 10px;
}
h5 {
margin-bottom: 0.5em;
}
.switch {
background-color: #fff;
border: 1px solid #999;
border-radius: 2px;
color: #fff;
cursor: pointer;
display: inline-block;
font-size: 0;
height: 34px;
overflow: hidden;
margin: 0;
padding: 0;
position: relative;
width: 80px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
.switch:after, .switch:before {
background-color: #9bca3e;
color: #fff;
content: "On";
display: block;
font-size: 13px;
line-height: 1.5;
height: 100%;
left: 0;
padding: 7px 0;
position: absolute;
text-align: center;
top: 0;
width: 51%;
/* This is so the darker color doesn't show through the rounded corners of the knob */
}
.switch:before {
background-color: #999;
content: "Off";
left: auto;
right: 0;
width: 50%;
}
.switch .knob {
background: #f7f7f7;
border: 1px solid #999;
border-bottom: none;
border-top: none;
border-radius: 2px;
display: block;
font-size: 13px;
height: 100%;
left: -1px;
position: relative;
top: 0;
width: 40px;
z-index: 2;
-webkit-transition: all 0.15s ease;
-moz-transition: all 0.15s ease;
-ms-transition: all 0.15s ease;
transition: all 0.15s ease;
}
.switch .knob:before, .switch .knob:after {
border: 4px solid transparent;
border-left-color: inherit;
content: "";
display: block;
height: 0;
left: 50%;
margin-left: 2px;
margin-top: -3px;
position: absolute;
top: 50%;
width: 0;
}
.switch .knob:before {
border-left-color: transparent;
border-right-color: inherit;
margin-left: -10px;
}
.switch input {
position: absolute;
visibility: hidden;
}
.switch input:checked + .knob {
left: 50%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="container">
<label class="switch">
<input type="checkbox" checked data-message="Checkbox 1"/>
<span class="knob"></span>
</label>
<div class="switch">
<input type="checkbox" checked data-message="Checkbox 2" />
<span class="knob"></span>
</div>
</div>
The change event fires fine on the first checkbox but not at all on the second. Is it something to do with the label sharing the event on the hidden input, whereas the div does not do this?
Testing here: https://jsfiddle.net/Twisty/947vsjpa/5/
You can see that Click events are happening on the Switch & Knob, yet not on the Input. The label element has a relationship with input. The click event upon the Label can effect the state of the Input. div does not have this relationship; therefore, the click event does not reach the invisible element.
How do you want to fix this? Use Label element for both? Capture the click event on the .switch and then trigger a click of the Input.
Consider the following: https://jsfiddle.net/Twisty/947vsjpa/18/
JavaScript
$(function() {
$('#container .switch').click(function(event) {
console.log(event.type, event.target);
event.preventDefault();
var $input = $("input[type='checkbox']", this)
$input.prop("checked", !$input.prop("checked"));
alert($input.data("message"));
});
});
This changes the property even if it's not visible and can't be clicked upon.
I am attempting to display tooltip like text using the data-title attribute for an HTML control.
I used the following technique for a element, and it works fine.
HTML Element:
<span class="spanNewID" data-title="Tooltip Text">816631-20319G14440 </span>
CSS Style:
span.spanNewID[data-title]:hover:after {
opacity: 1;
transition: all 0.1s ease 0.5s;
visibility: visible;
}
span.spanNewID[data-title]:after {
content: attr(data-title);
background-color: lightblue;
color: #111;
font-size: 12pt;
font-weight: bold;
position: absolute;
padding: 1px 5px 2px 5px;
bottom: -1.6em;
left: 100%;
white-space: nowrap;
box-shadow: 1px 1px 3px #222222;
opacity: 0;
border: 1px solid #111111;
z-index: 99999;
visibility: hidden;
}
span.spanNewID[data-title] {
position: relative;
}
The above code snippet works to correctly display my css based tooltip.
I am trying to apply the same selector to an element.
Consider the following:
HTML Element:
<input type="submit" value="Click Me" class="inuse" data-title="Input ELement Help"> </input>
CSS Style:
input.inuse[data-title]:hover:after {
opacity: 1;
transition: all 0.1s ease 0.5s;
visibility: visible;
}
input.inuse[data-title]:after {
content: attr(data-title);
background-color: lightblue;
color: #111;
font-size: 12pt;
font-weight: bold;
position: absolute;
padding: 1px 5px 2px 5px;
bottom: -1.6em;
left: 100%;
white-space: nowrap;
box-shadow: 1px 1px 3px #222222;
opacity: 0;
border: 1px solid #111111;
z-index: 99999;
visibility: hidden;
}
input.inuse[data-title] {
position: relative;
}
The hover text/tooltip does not display in this case.
I do not see any errors. There are no visible changes on the page.
I attempted to use the css selector in the Chrome "CSS Selector Tester" and the selector works as expected.
What am I missing/doing wrong here?
Thanks,JohnB
I did a bit of Googling myself, and came up with some interesting information. First off, pseduo-selectors :before and :after should be used on container elements.
Potentially you could use <button></button> instead of <input> and achieve the effect you desire:
.inuse[data-title]:hover:after {
opacity: 1;
transition: all 0.1s ease 0.5s;
visibility: visible;
}
.inuse[data-title]:after {
content: attr(data-title);
background-color: lightblue;
color: #111;
font-size: 12pt;
font-weight: bold;
position: absolute;
padding: 1px 5px 2px 5px;
bottom: -1.6em;
left: 100%;
white-space: nowrap;
box-shadow: 1px 1px 3px #222222;
opacity: 0;
border: 1px solid #111111;
z-index: 99999;
visibility: hidden;
}
.inuse[data-title] {
position: relative;
}
<button type="submit" value="Click Me" class="inuse" data-title="Input ELement Help">Click Me</button>
Or, and I'm sure you've considered this but it's worth mentioning anyway, just use the title attribute:
<input type="submit" value="Click Me" class="inuse" data-title="Input ELement Help" title="Input ELement Help">
When I hover over the first Div, the tooltip is shown further away than if I hover over the following two divs. Obviously it is because the text inside the div is larger/longer. But I don't want to show the tooltip span not depending on the hover text, but relating to the containing div of the text, so it is shown always at the same position.
jQuery is not an option for anything though but I kind of think, that it's a CSS problem anyway.
.subPhaseContainer {
float: left;
margin: 0 auto;
}
.projectItem {
margin: 4px;
border: 2px solid black;
cursor: pointer;
height: 17px;
}
.projectItem.green {
background-color: green;
color: white;
}
.projectNumber {
position: relative;
display: inline-block;
width: 80px;
}
.projectNumber .tooltiptext {
visibility: hidden;
width: fit-content;
text-align: left;
padding: 5px;
top: -1px;
position: absolute;
z-index: 1;
margin-left: 34px;
transition: opacity 0.3s;
border: 1px solid black;
}
.projectNumber .tooltiptext::after {
content: "";
position: absolute;
top: 20%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
.projectNumber:hover .tooltiptext.green {
background-color: green;
color: white;
visibility: visible;
opacity: 1;
}
.projectNumber:hover .tooltiptext.yellow {
background-color: yellow;
visibility: visible;
opacity: 1;
}
.projectNumber:hover .tooltiptext.red {
background-color: red;
color: white;
visibility: visible;
opacity: 1;
}
<div class="subPhaseContainer">
<div class="projectItem green">
<div class="projectNumber"><span>AAAA-00</span>
<span class="tooltiptext green">Tooltip Sample</span>
</div>
</div>
<div class="projectItem green">
<div class="projectNumber">
<span>BBB-11</span>
<span class="tooltiptext green">Tooltip Sample</span>
</div>
</div>
<div class="projectItem green">
<div class="projectNumber">
<span>CCC-22</span>
<span class="tooltiptext green">Tooltip Sample</span>
</div>
</div>
</div>
You need to specify either a 'left' or 'right' position for your tooltiptext span, otherwise its left/right position will be the same as it would have been had you kept the tooltiptext span positioned relative.
So just update your CSS for the tooltiptext to this:
.projectNumber .tooltiptext {
visibility: hidden;
width: fit-content;
text-align: left;
padding: 5px;
top: -1px;
right: -100%;
position: absolute;
z-index: 1;
margin-left: 34px;
transition: opacity 0.3s;
border: 1px solid black;
}
I am trying to code an input box like in the image below.
However, I only end up with part of the lines with the current code.
When it's a button rather than an edit, everything in fine.
.sidebar-search input {
display: inline-block;
border-color: #ffd717 -moz-use-text-color #ffd717 #ffd717;
border-style: solid none solid solid;
border-width: 2px 0 2px 0px;
color: #ffd717;
padding: 15px 25px;
position: relative;
overflow: hidden;
}
.sidebar-search input::before,
.sidebar-search input::after {
content: '';
width: 2px;
height: 160%;
position: absolute;
top: -30%;
background-color: #FFD717;
-webkit-transition: all 0.3s;
transition: all 0.3s;
z-index: 9999;
}
.sidebar-search input::before {
left: 10%;
}
.sidebar-search input::after {
right: 10%;
}
<div class="right-sidebar-area">
<div class="single-right-sidebar">
<div class="sidebar-search">
<input type="text" name="Search">
</div>
</div>
</div>
You are very close. It looks like ::before and ::after pseudo-selectors don't work for input elements, so apply it directly to sidebar-search and add more styles to that div
.sidebar-search {
/*specify positioning, height and width */
position: relative;
height: 50px;
width: 175px;
}
.sidebar-search input {
display: inline-block;
border-color: #ffd717 -moz-use-text-color #ffd717 #ffd717;
border-style: solid none solid solid;
border-width: 2px 0 2px 0px;
color: #ffd717;
padding: 15px 25px;
position: relative;
top: 5px;
overflow: hidden;
}
.sidebar-search::before,
.sidebar-search::after {
content: '';
width: 2px;
height: 160%;
position: absolute;
top: -30%;
background-color: #FFD717;
-webkit-transition: all 0.3s;
transition: all 0.3s;
z-index: 9999;
}
.sidebar-search::before {
left: 10px; /*these values are more accurate according to the picture */
}
.sidebar-search::after {
right: 10px; /*these values are more accurate according to the picture */
}
<div class="right-sidebar-area">
<div class="single-right-sidebar">
<div class="sidebar-search">
<input type="text" name="Search">
</div>
</div>
</div>
There are plenty of JavaScript-based libraries that show tooltips when you hover your mouse over a certain area of a web page. Some are rather plain, some allow the tooltip to display HTML content styled with CSS.
But is there a way to show a styled tooltip without using JavaScript? If you just use the title attribute, tags are not processed (e.g. foo<br />bar doesn't produce a line break). I'm looking for a solution that allows one to display styled HTML content without using any JavaScript.
I have made a little example using css
.hover {
position: relative;
top: 50px;
left: 50px;
}
.tooltip {
/* hide and position tooltip */
top: -10px;
background-color: black;
color: white;
border-radius: 5px;
opacity: 0;
position: absolute;
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.hover:hover .tooltip {
/* display tooltip on hover */
opacity: 1;
}
<div class="hover">hover
<div class="tooltip">asdadasd
</div>
</div>
FIDDLE
http://jsfiddle.net/8gC3D/471/
Using the title attribute:
Link
Similar to koningdavid's, but works on display:none and block, and adds additional styling.
div.tooltip {
position: relative;
/* DO NOT include below two lines, as they were added so that the text that
is hovered over is offset from top of page*/
top: 10em;
left: 10em;
/* if want hover over icon instead of text based, uncomment below */
/* background-image: url("../images/info_tooltip.svg");
/!* width and height of svg *!/
width: 16px;
height: 16px;*/
}
/* hide tooltip */
div.tooltip span {
display: none;
}
/* show and style tooltip */
div.tooltip:hover span {
/* show tooltip */
display: block;
/* position relative to container div.tooltip */
position: absolute;
bottom: 1em;
/* prettify */
padding: 0.5em;
color: #000000;
background: #ebf4fb;
border: 0.1em solid #b7ddf2;
/* round the corners */
border-radius: 0.5em;
/* prevent too wide tooltip */
max-width: 10em;
}
<div class="tooltip">
hover_over_me
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis purus dui. Sed at orci. </span>
</div>
This one is very interesting,
HTML and CSS only
.help-tip {
position: absolute;
top: 18px;
left: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before {
content: '?';
font-weight: bold;
color: #fff;
}
.help-tip:hover span {
display: block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip span {
display: none;
text-align: left;
background-color: #1E2021;
padding: 5px;
width: 200px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
left: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip span:before {
position: absolute;
content: '';
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom-color: #1E2021;
left: 10px;
top: -12px;
}
.help-tip span:after {
width: 100%;
height: 40px;
content: '';
position: absolute;
top: -40px;
left: 0;
}
<span class="help-tip">
<span > This is the inline help tip! </span>
</span>
Pure CSS:
.app-tooltip {
position: relative;
}
.app-tooltip:before {
content: attr(data-title);
background-color: rgba(97, 97, 97, 0.9);
color: #fff;
font-size: 12px;
padding: 10px;
position: absolute;
bottom: -50px;
opacity: 0;
transition: all 0.4s ease;
font-weight: 500;
z-index: 2;
}
.app-tooltip:after {
content: '';
position: absolute;
opacity: 0;
left: 5px;
bottom: -16px;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent rgba(97, 97, 97, 0.9) transparent;
transition: all 0.4s ease;
}
.app-tooltip:hover:after,
.app-tooltip:hover:before {
opacity: 1;
}
<div href="#" class="app-tooltip" data-title="Your message here"> Test here</div>
Another similar way to do it with CSS:
#img { }
#img:hover {visibility:hidden}
#thistext {font-size:22px;color:white }
#thistext:hover {color:black;}
#hoverme {width:50px;height:50px;}
#hoverme:hover {
background-color:green;
position:absolute ;
left:300px;
top:100px;
width:40%;
height:20%;
}
<p id="hoverme"><img id="img" src="http://a.deviantart.net/avatars/l/o/lol-cat.jpg"></img><span id="thistext">LOCATZ!!!!</span></p>
Try the Js Fiddle
Here are some links about transitions and other ways to do it:
http://www.w3schools.com/css3/css3_transitions.asp
http://dev.opera.com/articles/view/css3-show-and-hide/
You can use the title attribute, e.g. if you want to have a Tooltip over a text, just make:
<span title="This is a Tooltip">This is a text</span>
This is my solution for this:
https://gist.github.com/BryanMoslo/808f7acb1dafcd049a1aebbeef8c2755
The element recibes a "tooltip-title" attribute with the tooltip text and it is displayed with CSS on hover, I prefer this solution because I don't have to include the tooltip text as a HTML element!
#HTML
<button class="tooltip" tooltip-title="Save">Hover over me</button>
#CSS
body{
padding: 50px;
}
.tooltip {
position: relative;
}
.tooltip:before {
content: attr(tooltip-title);
min-width: 54px;
background-color: #999999;
color: #fff;
font-size: 12px;
border-radius: 4px;
padding: 9px 0;
position: absolute;
top: -42px;
left: 50%;
margin-left: -27px;
visibility: hidden;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:after {
content: "";
position: absolute;
top: -9px;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #999999 transparent transparent;
visibility: hidden;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:hover:before,
.tooltip:hover:after{
visibility: visible;
opacity: 1;
}