I have images that have statistics texts printed over them. This worked well with FF, Chrome and IE9 but not on IE8. I cant just seem to figure out what is the problem here.
HTML:
<div>
<div class="image">
<img src="#Url.Content("~/stuff/stuffImage.png")" alt="" />
<GIR1><span>#ViewBag.stuffArray[4]%</span></GIR1>
</div>
</div>
CSS:
.image {
position: relative;
width: 100%; /* for IE 6 */
}
GIR1 {
position: absolute;
top: 110px;
left: 50px;
width: 100%;
}
GIR1 span{
color: white;
font: bold 15px/15px Helvetica, Sans-Serif;
letter-spacing: -1px;
padding: 10px;
}
Instead of positioning the text inside the picture. It positions them outside it like normal text. What could cause the problem here?
I'm reasonably sure it's down to your usage of the custom element <GIR1>.
IE below version 9 does not natively recognize unknown elements.
You can either switch to <div class="GIR1"> (which would be the easy choice here), or:
You have to use a JavaScript fix: http://code.google.com/p/html5shiv/
Note that you'll have to add the custom element to the script yourself.
For the uncompressed version, see: http://www.iecss.com/print-protector/
var elems = 'abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video'
You need to add your custom elements to that list.
Related
I have an issue with the ::first-line selector in Chrome. In Firefox and even IE11 the result looks correct.
Here is what I expect it to be: Rendered in Firefox/IE11
Here is what I get in Chrome: Rendered in Chrome
But there is a weird behaviour in Chrome which results in a correct rendering:
open the developer panel (F12)
select the "t1b" item
untick the "box-shadow" property
tick it again
Here is a link to an example: jsfiddle.net/smc0hx78/
<body>
<span class="test">t1</span>
<span class="test firstLine">t1b</span>
<span class="test"><span>t2</span></span>
</body>
body {
font-size: 50px;
}
.test {
width: 2.5em;
height: 3em;
line-height: 3em;
display: inline-block;
position: relative;
overflow: hidden;
box-shadow: inset 50px -50px 0 0 cyan;
}
.test span {
font-size: 13px;
}
.firstLine::first-line {
font-size: 13px;
}
"t1" has no "first-line" (working fine in Chrome)
"t1b" has "first-line" (not working in Chrome)
"t2" has "first-line" but for a sub element (working fine in Chrome)
I need t1b to be working in Chrome.
Do I have any error in my CSS?
Is there a workaround without a sub element?
Thank you for any help.
This seems to be a Chromium Bug, though I have not found anything like that in the Github Issues (still, it could be resolved in a future release)
You have two options:
1 - Add an empty div before your spans. It seems to work if you put an empty block-element before your inline-blocks (don't know why)
<body>
<div></div>
<span class="test">t1</span>
<span class="test firstLine">t1b</span>
<span class="test"><span>t2</span></span>
</body>
or 2 - Change inline-block to inline-flex. The bug seems to affect only inline-blocks
.test {
display: inline-block; /* OLD */
display: inline-flex; /* NEW */
}
When using browsers web inspectors I came across two different and non-standard property for the CSS attribute vertical-align.
-webkit-baseline-middle is only available in Chrome while -moz-middle-with-baseline is available on Firefox. The naming is similar but NOT the same.
I couldn't find any information regarding these two on the web. They are not even listed on MDN.
My questions:
Are they part of any standards?
What is the expected behavior when
using them?
#VSG24:
Are they part of any standards?
Both properties are not part of any standards, according to W3C CSS reference. They only seem to be used by Webkit and Gecko to behave correctly, as expected in CSS 2.1 specification:
Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
CSS 2.1 specs, p170
#VSG24:
What is the expected behavior when using them?
After some search on the web, here's what I've found about -webkit-baseline-middle on the Safari CSS Reference:
vertical-align: -webkit-baseline-middle:
The center of the element is aligned with the baseline of the text.
I was unable to get any info about -moz-middle-with-baseline other than this one :
Q: Webkit-baseline-middle - are there alternatives?
A: the same, only for Mozilla >vertical-align: -moz-middle-with-baseline;
https://toster.ru/q/255210
Below is a test, you may try it using Webkit based browsers (such as Chrome) and Gecko (Firefox):
div {
width: 15%;
height: 100px;
display: inline-block;
box-sizing: border-box;
}
hr {
width: 100%;
position: absolute;
top: 90px;
height: 1px;
background: hotpink;
border: none;
}
.container {
border: 2px solid hotpink;
position: absolute;
top: 0;
left: 0;
height: 200px;
width: 100%;
z-index: -1;
}
.reference {
background: darkblue;
}
.standard {
background: teal;
vertical-align: middle;
}
.moz {
background: antiquewhite;
vertical-align: -moz-middle-with-baseline;
}
.webkit {
background: darksalmon;
vertical-align: -webkit-baseline-middle
}
<div class="container">
<hr />
<div class="reference"></div>
<div class="standard"></div>
<div class="moz"></div>
<div class="webkit"></div>
</div>
References :
Safari and WebKit implement a large subset of the CSS 2.1 Specification defined by the World Wide Web Consortium (W3C), along with portions of the CSS 3 Specification. This reference describes the supported properties and provides Safari availability information. If a property is not listed here, it is not implemented by Safari and WebKit.
Safari CSS Reference
Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification
Hope I helped a bit :)
I assigned a background image for a <div> in the CSS of my HTML code, i assigned the width and height and also add contents to the <div> but the bg still not shown, this is what I've tried:
CSS:
#order_list {
position: absolute;
width: 25%;
height: 100%;
z-index: 2;
left: 75%;
top: 35px;
color: #F33;
background:url(img/ItemList.png)
display: inline-block;
alignment-adjust: central;
font: Arial, Helvetica, sans-serif;
font-size: 14px;
font-size-adjust: inherit;
grid-rows: inherit;
list-style: upper-alpha;
word-spacing: inherit;
word-wrap: break-word;
vertical-align: central;
}
HTML:
<div id="order_list">
<div id="confirm" class="buttonClass">
<div align="center">Confirm</div>
</div>
<div id="total" class="totalClass">
<div align="center"></div>
</div>
</div>
screen shot:
It might depend on how your browser interprets it, but you forgot a semicolon at the end of
background:url(img/ItemList.png)
Without it, browsers won't show the image. Thanks to #Leeish for noting that in this case, a semicolon is absolutely neccessary.
; is missing at the end of background:url(img/ItemList.png) which is why you are not getting the background image.
Semicolon is needed to separate the declarations from one another.
It can be omitted from the last declaration in a CSS rule, but it is recommended so that later if you want to add more declarations, you won’t need to remember to add it in there.
I have an issue with the rendering of a tag on my page in IE. The problem lies in the following; the tag, in IE does not fill the tag. The picture is the link but in IE the text takes precedence and overrides the image to make the text a link. Chrome and FireFox have no issues and render fine. My question is:
How can I make the image the link in IE and get it to work like it does in Chrome and FireFox?
The following images showcase my problem:
The problem in IE:
How it should render as per Chrome and FireFox:
The code for the section is as follows:
h1#site-name, div#site-name /* The name of the website */
{
margin: 0;
font-size: 2em;
line-height: 1.3em;
height: 115px;
background: url('/sites/default/files/images/ipark2-theme-assets/iPark_title.jpg') no-repeat top right;
margin-left: 212px;
color: transparent;
}
#site-name a:link,
#site-name a:visited
{
color: transparent;
text-decoration: none;
display: block;
height: 100%;
filter: alpha(opacity=50);
font-size:1em;
}
EDIT: addition of html markup:
<div id="logo-title">
<div id="logo"><img src="/sites/all/themes/zen/ipark2/logo.png" alt="Home" id="logo-image" /></div>
<div id="site-name"><strong>
Teaching and Learning Innovation Park
</strong></div>
</div> <!-- /#logo-title -->
</div></div> <!-- /#header-inner, /#header -->
You're applying an ID to two elements (your H1 and your div), make use of classes as at the moment you're just slapping an ID on everything.
I'm not sure if that will solve your issue, but it won't hurt and I know older versions of IE are more strict about recognizing an ID if it's not unique. Since you're targeting your anchor tag through that ID, it just makes me question if it isn't the issue.
is there any solution to get support of CSS Gradient in firefox 3.5 and lower?
http://hacks.mozilla.org/2009/11/building-beautiful-buttons-with-css-gradients/
I would strongly advise you to just use a BG image. I know everyone can't wait to start using all the latest whiz-bang CSS3 features, but we're all just gonna have to wait for these parts of CSS3 to be adopted by the major browsers (which will happen before CSS3 reaches a W3C Recommendation).
Using vendor-specific extensions is a bad practice IMO and seems like a throw-back to the days when nobody cared about web standards, and web developers either, just coded for a single browser (along with tacky Designed for IE buttons), or had to write the same code multiple ways to support different browsers. All the major browsers now have support for PNG alpha layer transparency. So there's really little advantage to force the use of CSS to generate gradients. It only introduces unnecessary code redundancy.
If you're still set on absolutely not using BG images, then the only option is to use JavaScript. Here is a script that should work in Firefox 3 and up, perhaps even Firefox 2: JavaScript Gradient Roundrects.
The code would look something like:
var style = {
'gradient-start-color': 0x99ddff,
'gradient-end-color': 0xffffff,
'border-radius': 1
};
OSGradient.applyGradient(style, $('#Disp')[0]);
But this is still a roundabout way to achieve a result that could be obtained with a simple 1x50px PNG image.
While this article "Cross-Browser CSS Gradient" explain how to use the css3 gradient feature in all browsers, it is still limited to FireFox 3.6+.
So this old article from 2006 List Apart "Super-Easy Blendy Backgrounds" might offer an alternative (but not for all use case you might need)
CSS3 is going to implement a background-size attribute, but since CSS3 has an ETA of never, that’s no help now. So what do we do?
Well, we use something that will scale, like the img element. Instead of using a background to display the PNG blend, we can use an img element, and set the width and the height to 100%.
, with a CSS like:
<style type="text/css">.grad img {
height: 100%;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
z-index: 0;
}
.box {
border: solid orange 2px;
float: left;
margin: 1px;
position: relative;
width: 165px;
padding: 5px;
}
.box * {
margin: 0px;
position: relative;
z-index: 1;
}
* html .grad {
filter: progid:DXImageTransform.Microsoft.AlphaImage »
Loader (src='grad_white.png', sizingMethod='scale');
}
* html .grad img {
display: none;
}
* html .box {
position:static;
}
.blue {
background-color: #2382a1;
}
.green {
background-color: #4be22d;
}
.pink {
background-color: #ff009d;
}
</style>
<!--[if IE 7]>
<style type="text/css">
.box {
border: solid red 2px;
height:2.5em;
}
</style>
<![endif]-->
and the markup:
<div class="box grad blue">
<img src="grad_white.png" alt="blur gradient box" />
<p>Ooo, linked text!</p>
</div>
<div class="box grad pink">
<img src="grad_white.png" alt="pink gradient box" />
<p>Ooo, linked text!</p>
</div>
<div class="box grad green">
<img src="grad_white.png" alt="green gradient box" />
<p>Ooo, linked text!</p>
</div>