I am trying to use bootstrap tooltip for something it probably wasn't designed for, namely the possibility of showing a quite large text. I have managed to tweek it to my needs, with one exception. The width of the text box shown is way too narrow, unless i set it to a fixed width, but then it looks awfully stupid when displaying my short texts. I did override the standard max-width of 200px, but still it would not display even any wider than 120.797px
I tried to make a short simple example, and to my surprise, it works perfectly in my fiddle. with no width property set, it still grows to 800px, as set in max-width. So I tried to figure out what was different between my simple fiddle, and my larger web page. I used the google chrome dev-tools, to show me all set css properties, as I expected some unknown source to influence the width. Normally all properties set by css, are displayed with an arrow on the left side of each property, telling you exactly where, and through which file and selector statement this property is set. Here is what I found:
So, every other property gives a reference, while width remains a mysterious unknown. Notice that the font color is dark red. If this was calculated from other properties, it normally would be faded. I've tried to research what this might mean, but the official documentation leaves no clues. This page was the closest thing I could find.
How do I find out where this CSS-value comes from?
Here is a link to the fiddle. The tooltip text is a random news source from today, in norwegian. Code below, as per Stackoverflow rules:
HTML:
<span class="nav-text" data-toggle="tooltip" data-placement="right" title="" data-original-title="– Vi har nok satt oss litt i respekt i dag for de andre nasjonene. De vet nå at vi ikke er uredde og ikke er redd for å bare gå fra dem i front, sa Johannes Thingnes Bø om den solide seieren.
For da Emil Hegle Svendsen sendte Johannes Thingnes Bø ut på den siste etappen sammen med franske Antonin Guigonnat og italienske Therry Chenal var det mye som skulle gå galt for at ikke stryningen skulle sikre norsk stafettseier.
Og stryningen gikk knallhardt ut og viste konkurrentene ryggen allerede i den første motbakken.
– Jeg er ganske trygg og selvsikker når jeg går ut på siste etappe, sa ankermannen til NRK etter målgang.
En god generalprøve før OL
Det var et godt fornøyd stafettlag etter seieren. Stafetten i Ruhpolding var den store generalprøven for det som skal være det norske OL-laget i Pyeongchang i februar.
– Det var en god følelse. Jeg tar gjerne samme løpsopplegg neste gang det er stafett, sa Thingnes Bø etter seieren med et klart hint til stafetten i OL.">
Hover for tooltip
</span>
CSS:
div.tooltip{
top:0px !important;
}
div.tooltip>div.tooltip-arrow{
top:15px !important;
}
div.tooltip>div.tooltip-inner{
max-width:800px !important;
white-space: pre-wrap;
text-align: left;
}
And standard init of bootstrap tooltip, javascript:
$('[data-toggle="tooltip"]').tooltip();
Related
My question is very different from this question: Font scaling based on width of container
This previous question and answers do not mention the ch unit.
CSS Tricks shows an example of using the ch unit to size text, https://css-tricks.com/almanac/properties/f/font-size/.
I had assumed that setting font-size to say 75ch would set the font size so that a maximum of 75 characters (or zeros) would fit on a line, within its container. So that when the container width grows or shrinks, the font-size adapts accordingly, so that there is always 75 characters per line.
See The Elements of Typographic Style Applied to the Web http://webtypography.net/2.1.2 "Anything from 45 to 75 characters is widely regarded as a satisfactory length of line"
However it doesn't work like that. I can see the max-width: 75ch limits the width of the text to 75 characters. But that is an entirely different thing.
If the ch unit can't be used on font-size to create responsive font sizes depended on the width of the container, then what is ch based on when used on font-size (as per the CSS Tricks example)?
<div class="text-content">
<p>Nus moluptatur? Quid eum in nosandit, ut voluptae num dit faccumquis qui vollab inctaquam, undis antis et voluptae. Itatenditem qui tem nonecus repedi doluptae pre explautessum is dolupta doluptatum que perunt lant rero te dolestium fugitat emporeiur, ipit est od minim dolesti asitati onsedisci dit magnatecatur se nimini repe est voluptat. Alitatur seruptat. Dercipis nonsequ iandae venim erum que rerionectas ad quate aut undi dis es alit adis dia dio te miligen tinvelis nustis mi, ut militatur atiosam, etur aut eum ut ad qui nonet fugiam facculpa pro molenis et, consenim volorer ercienis endaniste est ut exeria dis voluptam si dolorat. Tationsed maximpellant maximod eiunt undisque imustruntus mintio blant lamet ea volupta tiores ducita qui dolut aut ex ex enitas soluptur? Ebit eium et et exeruntur? At autatisquas siti cone cuptaspedit lamusae sequidi coreperion ea illaut liquaec tusamus, aborepra qui to ellabore vellace atemporemqui ulparchilia nis sit utet is abo. Sa susdaerumquo voluptatibus corro que et laboribus repudipid es is vid maio. Ut doluptate conseniet que volumquia quam excerib erspernamet dolorio. Itaturehenti sum, estiur sinusciliquo bla es enimus autate ex entotas consendio. Ut lit optatibustes vit ute que mo milliciati re, odi dolum re velesto rercitae re elenis exerit omniate et, cuptibusdae quamus.</p>
</div>
.text-content {
max-width: 700px;
}
p {
font-size: 75ch;
}
See JS Fiddle https://jsfiddle.net/n98oq5Lc/
ch as a unit really only makes sense in most cases if you are dealing with a monospaced font - then 75ch max-width really would mean dont let the width go beyond 75 characters. But with non monospaced fonts CSS isn't going to count the characters it's going to use what it deems the width ch to mean (see e.g. https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units If your text is lots of i characters it will have a different number of characters in the element than if it has lots of M.
You can however get a sort of responsive font size by defining it in terms of vw and your element width in terms of vw too. It wont gaurantee how many characters you get in a line (unless you go back to the monospaced idea) though.
I tried CH and it sucks, cause lets say you have word: LISBON ... first 2 characters LI are the same size as S, so based on max-width: 2ch; => LI-S-B-O-N
if you try ch3, then it will be LIS-B-ON
basically doesn't work as intented.
No.
ch is a width but font size is a height.
So 75ch merely adjust the vertical size of the font, not the width in respect to the container.
So, this issue has come up before, like here: Translate + Canvas = Blurry Text
and here: Is it possible to "snap to pixel" after a CSS translate?
There doesn't seem to be any conclusions on either of those links—or any other articles I've read. Some responders didn't think it was important enough to care, so here is why in my situation it is: Screenshot in Chrome 41.0.2272.104
Screenshot in Safari 8.0.4 (10600.4.10.7)
See the loss in detail in Safari? (look at the structure in the space-shuttle image, or the detail in the rocks in the 3rd image)
The CSS for these guys is
width: 100%;
height: auto;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
So, in some of these situations—the translateY will end up in a half pixel. The first image on the left ends up with a transform matrix like so:
-webkit-transform: matrix(1, 0, 0, 1, 0, -56.5);
At the current time, it seems chrome is rendering this nicely (i've seen some folks say different browsers create the issue in different versions), but currently Safari is having the issue. So, my assumption to fix this issue is to make sure that there are only whole pixels, which I've already done by doing the math and applying the transform in javascript, but this costs more in performance time when running on a lot of images.
I've tried a few CSS-only hacks like using scale3d with no success. If anyone has any JS-free solutions, I would much appreciate the shared knowledge.
In some browsers, you can take advantage of floating point rounding errors from calc to round your number to the nearest increment desired:
calc((2.55px * 5e-324) / 5e-324)
should cause 2.55px to get rounded up to 3px. The supporting browsers are Chrome (including derivatives like Brave, Electron, Edge, and Opera) while the unsupporting browsers are IE, Firefox, and Safari (including derivatives such as Midori). Thankfully, the unsupporting browsers, IE, Firefox, and Safari, just disregard the calc as being an invalid property value because the numbers used are outside the acceptable range. So, to utilize this, just use the example below to generate CSS to suit your needs. Yes, I know that this generator doesn't always combine like-terms, and yes, there is a reason: combining those like-terms would create a number unable to be stored.
var unit = document.getElementById('unit'),
precision = document.getElementById('precision'),
property = document.getElementById('prop'),
output = document.getElementById('output');
function formatProp(x) {
return (property.value.indexOf('%s') ?
property.value.replace(/%s/g, x) :
proprty.value + x).replace(/\\n/g, '\n')
.replace(/\\t/g, '\t').replace(/\\r/g, '\r');
}
(unit.oninput = precision.oninput = property.oninput = function() {
var Val = parseFloat(precision.value),
V1 = "5e-324",
V2 = "5e-324";
if (Val < 1)
V1 = V2 = '' + 5e-324 / Val;
else if (Val > 1)
V2 += ' * ' + Val, V1 += ' / ' + Val;
output.textContent = formatProp(unit.value) + '; /* for IE and FF*/\n' + formatProp('calc((' + unit.value + ' * ' + V1 + ') / ' + V2 + ')') + ';';
})();
CSS Unit: <input type="text" id="unit" value="-50%" style="width:14em" /><br /> Property : <input type="text" id="prop" value="-webkit-transform: translateY(%s);\ntransform: translateY(%s)" style="width:40em" /><br /> Round to: <input type="number" id="precision"
value="1" style="width:14em" /> pixels (can be decimal)<b5 />
<pre id="output" style="background:#eee"> </pre>
Please note that as per the lingual definition of real-time responsive, yes, you can enter in your own values into the demo above, and yes, the corresponding CSS will be generated realtime.
My Testing Page I created: purposeful-rounding-errors browser support test
Please note that while the chart above features currently supporting browsers, it is very much subject to change because utilizing rounding errors is sort of non-standard: the W3C spec only implies them in the definition of a floating point number, but does not ever explicitly state that browsers need to implement sub-normal floating point notation, or rounding errors.
I have a site I created: http://www.raggeddaisy.com
On my Wooden Signs pages and Chalkboards pages, the 'Request More Information', only the top little bit of the button is clickable. The code is the same as my Magnetic Board and Wooden Benches pages. Why would this be? Thanks in advance for your help.
<div id="requestInfoButton">
<form action = "ContactUs.cshtml">
<input type="submit" class="button" value="Request More Information">
</form>
</div>
#requestInfoButton {
font : 10pt 'Century Gothic';
padding-top : 2.25pt;
position : absolute;
left : 500.00pt;
top : 400.50pt;
width : 150pt;
height : 16.50pt;
}
That's because your div with id 'optionsWoodenSignLargePrice' is covering it. I wouldn't advice the styling you've used for just the text and especially the absolute positioning.
However, removing the width and height attributes from the div#optionsWoodenSignLargePrice styles does solve your problem.
It looks like you have two divs that are absolutely positioned with a fixed width that cover the majority of that request more info button. If you remove the width on div#optionsWoodenSignSmallPrice and div#optionsWoodenSignLargePrice your button will be clickable.
I have Textview.am getting web response in the fallowing way
asdgfsagasgs
asdsa sa sad asd sada sdas
asdsad ad sad sad sad ad asdsad
asdsadsadsadsadsadsad
asdsadsadsadsaddsadsadasdasdasda sda asd
sdasdsadasdsadsadsadasdasdads
sadasdsadasddsad
asdsadsadas sad sad sad asd
sadasdas sad sadsaas sad
asdas sa sa asd sad asd asd asd asd
asddsadsadasdasd
asddsadsadasdasdasddsadsadasdasd
asddsadsadasdasd
asddsadsadasdasdas ddsadsadasdasdasddsa dsadasdasdasddsadsadasdasd
asddsadsadasdasdasddsadsadasdasd
asdasdsadsadads
how can i set to layout for apply span style color and every thing.
Try this to set textview style to bold and italic
textView.setTypeface(null, Typeface.NORMAL); // for Normal Text
textView.setTypeface(null, Typeface.BOLD); // for Bold only
textView.setTypeface(null, Typeface.ITALIC); // for Italic
textView.setTypeface(null, Typeface.BOLD_ITALIC); // for Bold and Italic
You can use this to change style of specific word as:
textview.setText(Html.fromHtml("<b>" + Year: + "</b>"+"2012,
"+"<b>" + Language: + "</b>"+":Armenian,"
"+"<b>" + Subtitles: + "</b>"+":English"));
Also You can go for SpannableString for Creating an String with different fonts,colors or style.
SpannableString(CharSequence source)
Here is a portion of my code:
var styles:String = ".keyword{color: #ff0000;} .comment{color: #00ff00;}";
var myStyleSheet:StyleSheet = new StyleSheet();
myStyleSheet.parseCSS(styles);
myTextArea.htmlText = '<span class = "keyword"> red </span> uncolored <span class = "comment"> green text</span>';
Everything is fine till this point, i can edit my text, of course everything is showed in black, and the html-tags are ignored. But when I put this code in myTextArea.styleSheet = myStyleSheet;
my text will be colored as i want it to be, but the textArea will become uneditable (no blinking pointer, no reaction on keyboard press).
After each keyboard-press (or if the time between two key-presses is bigger than x milliseconds ) i will re-render the textArea.text and append the <span class = "keyword"> where needed </span> tags and put it into the textArea.htmlText, but can't seem to figure it out how to do it when style is applied.
Sadly enough css and text input are incompatible. The only workaround is to use TextFormat instead. Sorry for being disappointing...