Absolute positioning and scroll bar in Internet Explorer - html

Disclaimer
This question is a repost. I originally asked it here. While there was one person who was kind enough to help me, he ultimately couldn't find an ideal solution. The reality of the situation is Doctype just doesn't have the huge number of users that Stack Overflow does. This is an important problem for me, and I really need more opinions on it.
The Problem
I've implemented a tree view using HTML and CSS. When an item in this tree view is hovered, a tooltip appears under it. Everything's works great in Firefox, but not in Chrome or Firefox.
My problem is the tooltip is using absolute positioning to allow its content to display over other elements. When I scroll in Firefox, the positioning of these tooltips moves to reflect their new locations. However, Internet Explorer retains the original position of the elements. Thus if I hover over a scrolled elements, the tooltip displays under wherever the element was originally located.
I've read this could be fixed by adding position: relative to my tree view, but this would prevent the tooltips from hovering over the entire page.
Here's some example code to illustrate my problem:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
<!-- import css files -->
<link href="example.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="tree-view">
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
<a href="#">tooltip example
<span class="tooltip">
<strong>Info</strong>
<span class="tooltip-info">
Here is some information about the thing you're hovering over.
</span>
</span>
</a>
</div>
<div id="main-content">
main
</div>
</div>
</body>
</html>
And here's the CSS for the example:
#wrapper
{
}
#tree-view
{
float: left;
width: 200px;
height: 400px;
background-color: #BBFFFF;
overflow: auto;
}
#main-content
{
float: left;
width: 600px;
height: 400px;
background-color: #FFFFBB;
}
#tree-view a
{
display: block;
position: relative;
}
#tree-view a span.tooltip
{
position: absolute;
z-index: 100;
display: none;
}
#tree-view a:hover span.tooltip
{
/* positioning */
margin-left: 1em;
margin-top: 1em;
display: block;
position: absolute;
/*formatting*/
text-decoration: none;
background: #DDD;
border: 1px solid #BBB;
padding: 5px;
white-space: normal;
width: 300px;
color: black;
}
#tree-view .tooltip strong
{
display: block;
}
#tree-view .tooltip .tooltip-info
{
display: block;
}
If the position: relative tag is removed from the tooltip anchor, the tooltips display correctly in Firefox. However, without it the tooltips don't display correctly in Internet Explorer.
Thanks for the help.

I stopped using my own Tooltips and switched over to Qtip (http://craigsworks.com/projects/qtip/)a while back. It's cross-browser tested, simple to instantiate, and looks outstanding. If you happen to be a ThemeRoller user, the beta version (available in the nightly builds) fully supports ThemeRoller styling. Overall, I'd highly recommend considering it to make life easy....it's just less brain-damage.
In the upcoming release of JQuery UI, there will be a similar feature built into the core. Similar scripts are available for Dojo, Prototype, and MooTools.

The code you posted works straight away in Firefox.
The tooltips don't show up in IE6, rather strangely you can fix this by giving the hover state of the anchor a background color...
#tree-view a
{
background-color:#ff0000;
}
I guess it just needs to have layout but the usual zoom:1; or position:relative; don't have the same effect
You can remedy the scroll bars by using...
#tree-view
{
overflow: display;
}

Related

Bring element infront of other element without touching other elements

I have this structure:
<div class="destination full">
<span class="sign">?</span>
<span class="word" data-id="0.705074201440127">this</span>
<span class="word" data-id="0.36336623481795605">is</span>
<span class="word" data-id="0.8481199104419181">magical</span>
<!-- <span class="word" data-id="0.84811991044191851">add or remove</span> -->
</div>
Note that we can add or remove word elements. The issue is to find a proper CSS solution to brig sign element in front of all other words (to create a question sentence right?) with touching word elements (I mean I still want the sentence to be meaningful)
NOTE: We can not touch the structure of the HTML .
.destination {
display: inline-flex;
gap: 0.3ch;
}
.sign {
order: 1;
}
<div class="destination full">
<span class="sign">?</span>
<span class="word" data-id="0.705074201440127">this</span>
<span class="word" data-id="0.36336623481795605">is</span>
<span class="word" data-id="0.8481199104419181">magical</span>
<!-- <span class="word" data-id="0.84811991044191851">add or remove</span> -->
</div>

Semantic song markup with visual "chord stacking"

I am looking for a HTML-based representation for song texts with chords above the syllables, in the following fashion:
Am C D F
There is a house in New Orleans
Now, I don't care how exactly the HTML looks like in the end, but there is an important constraint: the purpose is not only display, but also storage in a semantically meaningful representation. Specifically, the songs are converted from a LaTeX-based syntax and should be recoverable in their original form, as well as being readable in HTML and easily processable. So no fancy structure just for the purpose of presentation, and no JavaScript (yes, I have looked at how UltimateGuitar does it, that is exactly not what I want). I need every element to have a direct correspondence to some logical part, as in the original format.
On the other hand, this gives me a hard time designing a CSS that presents the stacked chords. The basic rule is that you have "boxes" consisting of a text part and a chord part, and the width of the whole box should be the maximum of either parts, which each can consist of arbitrarily long text:
Am Cmaj7/G Am G F Am/G E7 F#sus4 A
longstuff short multichord more end. e - ternal
The boxing structure is known in advance, so you can assume it as given:
((Am) (longstuff))
((Cmaj7/G) (short))
((Am G) (multichord))
((F Am/G) (more))
end.
((E7) ())
((F#sus4 A) (e))ternal
Note that in the last box, the word is hyphenated to compensate for the two chords on the first syllable. I fear this makes it very hard for CSS, so it might be represented in a slightly different way, e.g.
((F#sus4 A) (e) (ternal))
You can come up with alternatives, as long as they still have concise semantic meaning. Here is what I have come up with so far:
.verse {
line-height: 3rem;
font-family: serif;
}
.cbox {
border: 1px solid;
}
.chord {
position: absolute;
transform: translate(0, -1.1rem);
font-weight: bold;
font-family: monospace;
user-select: none;
font-size: large;
}
<p class="verse">
Test
<span class="cbox"><span class="chord">Abc</span>X</span>
<span class="cbox"><span class="chord">Abc</span>Xyzwv</span>
<span class="cbox"><span class="chord">Abc</span>Xyzw</span>abc
sd
<br/>
Test
<span class="cbox"><span class="chord">Abc De</span>Xy</span>zwv
sd
<br/>
<span class="cbox"><span class="chord">Ab</span>xyz</span>
<span class="cbox"><span class="chord">Abc#sus4/C</span>Zyzw xyz</span>
<span class="cbox"><span class="chord">Am</span>xyzw</span>
<br/>
<span class="cbox"><span class="chord">D</span>xyz</span>
<span class="cbox""><span class="chord">E7</span></span>
two
<span class="cbox"><span class="chord">E7</span>th</span>ree
</p>
The sizes and borders are chosen for debugging. As you can see, the width of the top (chord) part is not taken into account (because position: absolute prevents that).
I have tried some other variants, including this one: <span class="cbox" data-w="2" data-c="Am">longstuff</span>, where data-w is the number of letters in the chord name to be used in the min-width of the span, and data-c being put into a before pseudo-element, but I still didn't succeed at getting the width right.
For the hyphenation issue, I have no idea at all.
And I will likely be using XHTML, although I guess this won't make much of a difference.
I'd suggest using CSS grid to help keep things from overlapping.
You can specify a grid template of 1 column and 2 rows, and then use classes to tell the content which row it should fit into. The grid will fill nicely and create implicit new columns as needed. It even will work if you have a series of chords or text in a row, without needing to wrap chord/text pairs in a wrapping element.
For the hyphenation, if possible, I'd add an additional class to syllables that need hyphenation, and then create the hyphens using a pseudo element in CSS.
Here's a working example. Hope this is helpful. This was a fun challenge.
.line {
display: grid;
justify-content: start;
grid-template-columns: auto;
grid-template-rows: auto auto;
grid-auto-flow: column;
gap: 0 0.6em;
margin-bottom: 1em;
}
.chord {
grid-row-start: 1;
}
.text {
grid-row-start: 2;
}
.hyphenated:after {
content: ' - '
}
<span class="line">
<span class="chord">Am</span>
<span class="text">longstuff</span>
<span class="chord">Cmaj7/G</span>
<span class="text">short</span>
<span class="chord">Am G</span>
<span class="text">multichord</span>
<span class="chord">F Am/G</span>
<span class="text">more</span>
<span class="text">end.</span>
<span class="chord">E7</span>
<span class="chord">F#sus4 A</span>
<span class="text hyphenated">e</span>
<span class="text">ternal</span>
</span>
<hr>
<p class="verse">
<span class="line">
<span class="chord">C</span>
<span class="text">Frosty the</span>
<span class="chord">C7</span>
<span class="text">snowman</span>
</span>
<span class="line">
<span class="text">was a</span>
<span class="chord">F</span>
<span class="text">jolly</span>
<span class="chord">F#dim</span>
<span class="text">happy</span>
<span class="chord">C</span>
<span class="text">soul</span>
<span class="chord">C7</span>
</span>
<span class="line">
<span class="text">with a</span>
<span class="chord">F</span>
<span class="text">corncob</span>
<span class="chord">F#dim</span>
<span class="text">pipe and a</span>
<span class="chord">C</span>
<span class="text">button</span>
<span class="chord">A7</span>
<span class="text">nose</span>
</span>
<span class="line">
<span class="text">and two</span>
<span class="chord">Dm7</span>
<span class="text">eyes made</span>
<span class="chord">G7</span>
<span class="text">out of</span>
<span class="chord">C</span>
<span class="text">coal.</span>
<span class="chord">C7</span>
</span>
</p>
Edit: A downside to the above approach is that the content is hard to understand if unstyled.
A more semantic approach could be to combine CSS Grid with content defined in custom data-* attributes and CSS variable fallbacks. This way the chords stay stored as attributes rather than marked-up text interspersed with the lyrics.
.verse {
line-height: 2;
}
.lyric {
display: inline-grid;
grid-template-columns: auto;
grid-template-rows: auto auto;
line-height: 1;
}
.lyric[data-chord] {
--chord: attr(data-chord);
}
.lyric:before {
content: var(--chord, '\00a0');
}
<p class="verse">
<span class="lyric" data-chord="C">Frosty the</span>
<span class="lyric" data-chord="C7">snowman</span>
<br>
<span class="lyric">was a</span>
<span class="lyric" data-chord="F">jolly</span>
<span class="lyric" data-chord="F#dim">happy</span>
<span class="lyric" data-chord="C">soul</span>
<span class="lyric" data-chord="C7"></span>
<br>
<span class="lyric">with a</span>
<span class="lyric" data-chord="F">corncob</span>
<span class="lyric" data-chord="F#dim">pipe and a</span>
<span class="lyric" data-chord="C">button</span>
<span class="lyric" data-chord="A7">nose</span>
<br>
<span class="lyric">and two</span>
<span class="lyric" data-chord="Dm7">eyes made</span>
<span class="lyric" data-chord="G7">out of</span>
<span class="lyric" data-chord="C">coal.</span>
<span class="lyric" data-chord="C7"></span>
</p>
This creates a one-column, two-row, inline grid for each .lyric span. The value of --chord is set to the value of the data-chord property only on elements that have that property. It's then used in all .lyric elements to set the content of the :before pseudo-element, with a fallback to a non-breaking space if the variable is undefined. This is important because it pushes the text into the bottom row for .lyric spans that don't have a chord, and keeps the text horizontally aligned.

The 5 star ranking "width" % from 0 - 100% in CSS only works with the 20/40/60/80/100 but not for example 70%

I have a problem. I work with mustache code to trigger the content.
Now I have a 5 star review rating in the website but to trigger the content without going in the code I made the overlay with the mustache code. Everything is working fine. But if, for example, in the source code the rating is 4.5 stars, it doesn't fill the stars. But in the source code the class is changed to bcrating4.5.
This is my code:
<span class="rating bcrating{{rating}}"></span>
The rating class is the original code from the site.
The bcrating is the class below in the CSS code.
The mustache {{rating}} is the trigger code.
<p id="hiddenrating" hidden>{{rating}}</p>{{#recommendations}}
<ul class="box-content box-related" id="viewed-product-list">
<li class="item" style="width:16.57%">
<div class="item-info grid_2 alpha"> {{#image}}
<a class="product-image" href="{{URL}}" title="{{name}}">
<img src="{{image}}" alt="{{name}}" style="width:50%">
</a> {{/image}}
<div class="product-details">
<a href="{{URL}}" title="{{name}}">
<span class="product-name">{{name}}</span>
<div class="price leden">
<span class="old_price">
<strong>{{old_price}}</strong>
</span>
<span class="new_price">
<strong>{{new_price}}</strong>
</span>
</div>
</a>
<div class="product-review-block">
<span class="fivestar">
<span class="rating-box">
<a class="nobr" href="{{URL}}#customer-reviews-tab">
</a>
<span class="rating bcrating{{rating}}"></span>
</span>
</span>
</div>
</div>
</div>
</li>
</ul>{{/recommendations}}
CSS:
.bcrating0 {
width:0%;
}
.bcrating1 {
width:20%;
}
.bcrating2 {
width:40%;
}
.bcrating3 {
width:60%;
}
.bcrating4 {
width:80%;
}
.bcrating5 {
width:100%;
}
If {{rating}} passes in a value of "4.5", your class name for that .rating element in HTML is bcrating4.5. HTML can have periods as part of a valid class name.
In your CSS you only have classes .bcrating4 and .bcrating5. Nothing matches.
You need to define a class .bcrating4\.5 where the period character is escaped, making it a valid selector in CSS that matches your HTML.
This is a handy character escaping tool: https://mothereff.in/css-escapes

Bootstrap: Two elements in one line?

I have a problem with my verified icon.
So what I actually want is that the verified Icon like on Twitter or Facebook is besides the Username and not in the next line under my username.
But it does not work.
<ul class="line">
<li>
<h3 align="center">Username</h3>
<span class="label label-info">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</span>
</li>
</ul>
Here is my CSS:
li.line {
list-style: none;
}
ul.line {
display: block;
}
h3 is a block element
change it to inline element
<ul class="line">
<li>
<span align="center">Username</span>
<span class="label label-info">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</span>
</li>
</ul>
If you don't want the list point, then I don't think li is what you'll want to use. A span or even a div could probably give you the look you're going for.
As for having them on the same line, try using the inline-block option for your css display element. It is similar to display: block, but it allows you to keep your elements on the same line.

Background-color and border misbehaving in IE version 11 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I am struggling to make IE 11 behave like Chrome and FF and I'm not sure what to do...
This is the code:
#main {
position: relative;
top: 20px;
height: 400px;
-webkit-background-color: rgba(72, 72, 72, 0.2);
background-color: rgba(72, 72, 72, 0.2);
/*background-color: #484848;*/
width: 460px;
margin: 0 auto;
-webkit-border-radius: 5px;
-webkit-border: 1px solid #a1a1a1;
border-radius: 5px;
border: 1px solid #a1a1a1;
}
And this is the effect visually...
The background-color being translucent is being ignored and so is the border-radius. Also, Chrome behaves the same as FF...
Any tip would be appreciated
Dennis
Here is the HTML for that section:
<main id="main">
<div id="resultContainer">
<section id="i0" class="wDay">
<h2>
<span class="day" ></span>
<span class="temp" ></span>
</h2>
<img src="">
<span class="wDescript" style="color:#2050ff;word-break:break-all;"></span>
<span class="wind" ></span><br/>
<span class="humid" ></span>
<span class="other1" ></span>
<span class="other2" ></span>
</section>
<section id="i1" class="wDay">
<h2>
<span class="day" ></span>
<span class="temp" </span>
</h2>
<img src="">
<span class="wDescript" style="color:#2050ff;word-break:break-all;"></span>
<span class="wind" ></span><br/>
<span class="humid" ></span>
<span class="other1" ></span>
<span class="other2" ></span>
</section>
<section id="i2" class="wDay">
<h2>
<span class="day" ></span>
<span class="temp" </span>
</h2>
<img src="">
<span class="wDescript" style="color:#2050ff;word-break:break-all;"></span>
<span class="wind" ></span><br/>
<span class="humid" ></span>
<span class="other1" ></span>
<span class="other2" ></span>
</section>
<section id="i3" class="wDay">
<h2>
<span class="day" ></span>
<span class="temp" </span>
</h2>
<img src="">
<span class="wDescript" style="color:#2050ff;word-break:break-all;"></span>
<span class="wind" ></span><br/>
<span class="humid" ></span>
<span class="other1" ></span>
<span class="other2" ></span>
</section>
</div>
</main>
Pull up developer tools and make sure the browser is in standards mode. If you are in compatibility mode, you wouldn't see those styles in IE.
Try adding the X-UA-Compatible meta tag to force standards mode.
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
Today is August 8, 2014 and Microsoft does not support the <main> tag. div, section, article etc work just fine...
So, thank you all for the effort to help.
Regards,
Dennis