CSS-styled <figure> of circle will not display in print-view - html

I have created some 3D spheres with figure html elements and css-styling that I cannot get to display in a print-view. I am trying in both IE9 as well as Chrome v45. What can I do to get these to print? I hope the answer is not to change the element to something other than figure as this would require numerous other changes.
I have
-- checked "print background colors an images" in IE print dialogue and I've checked "background graphics" in Chrome print dialogue.
-- tried adding -webkit-print-color-adjust: exact; to a number of places in the css, including figure{}, .sphere{} and .red{}
-- tried adding a print-backgrounds chrome extension, which I later learned was obsolete anyway.
HTML:
<figure class="red sphere"></figure>
CSS for Chrome:
.sphere {
display: block;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
height: 30px;
width: 30px;
margin: 5px auto auto auto;
}
.red {
background: radial-gradient(circle at 10px 10px, red, #000);
}
CSS for IE9:
.sphere {
display: block;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
height: 30px;
width: 30px;
margin: 5px auto auto auto;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100, finishopacity=40, style=2);
}
.red {
background: red;
}
Thanks!

When linking your stylesheet make sure to have media=all in the link.
It should look something like this:
<link rel="stylesheet" type="text/css" media="all" href="styles.css">
or set up a specific print stylesheet like so:
<link rel="stylesheet" type="text/css" media="print" href="print.css">

Funny thing, after nearly 3 years I was finally asked (again) to create a print view for the MVC application in question here. So I googled my question (again) and thought 'this person is asking just what I'm after!'. Yep, turns out it was my own question (and still unanswered) ...
Gained from my own experience, and searching other code I'd written since first asking my question, here is the answer, ...
#media print
{
.red {
background: radial-gradient(circle at 10px 10px, red, #000) !important;
}
.yellow {
background: radial-gradient(circle at 10px 10px, yellow, #000) !important;
}
.green {
background: radial-gradient(circle at 10px 10px, #00af00, #000) !important;
}
}
Yep, I just had to re-describe the background color characteristics (and include !important) in the #media print section of the css file. Why? Idk. It's a direct copy/paste (plus !important) of the general css section. But it worked!
Cheers!

Related

css3 not working in compatibility mode, any alternative?

quite simply I want to make an animated tile type button.
I'm not sure what the issue is (probably an outdated server) but css3 properties don't work. (I'm using ie11 so I know they should work on my browser).
below is my code, what isn't working is RGBA or transition (which I believe to be CSS3 attributes, please correct me if I'm wrong)
any help on a workaround would be greatly appreciated, I tried to use modernizr but it just completely bamboozled me.
<!DOCTYPE html>
<html>
<head>
<title>title</title>
<link rel="stylesheet" type="text/css" href="CSS/StyleSheet.css">
<style>
.tile{
height: 190px;
width: 190px;
overflow: hidden;
background-repeat: no-repeat;
max-width: 100%;
text-align: center;
vertical-align: middle;
background-size:190px 190px;
}
.caption{
background-color: rgba(0,0,0,0.4);
overflow: hidden;
color: #fff;
font-weight: bold;
margin: 150px 0px 0px 0px;
height: 190px;
width: 190px;
}
.caption:hover {
transition: margin .5s;
margin: 0px 0px 20px 0px;
background-color: rgba(0,0,0,0.4);
cursor: pointer;
}
#description{
overflow: hidden;
margin: 25px 0px 0px 0px;
}
</style>
</head>
<body>
<h1>Welcome</h1>
<div class="tile" style="background:url('images/tile1.jpg'); background-size:190px 190px" >
<div class="caption" onclick="alert('test');" >
<p>Some caption</p>
<p id="description">Some lengthy description that may potentially overflow into two lines</p>
</div>`enter code here`
</div>
</body>
</html>
edit::
as per my lower post this is actually due to compatibility mode, this will be forced on the majority of people using the site so does anyone know if a workaround?
Regarding Transparency
The transparency via the background: rbga(...) property appears to be working just as expected in Internet Explorer 11 per your example:
Another option would be to use the CSS opacity property, which functions similar to your use-case, however it just handles the transparency level. It does functiona a bit differently however as it is applied to the targeted element and all children of the element, so it isn't always the most appropriate choice.
opacity: 0.4;
If the transition is the issue...
If you want the transition to appear when you hover out of the element, you'll also need the transition property on your non-hover selector as well :
.caption{
/* Other properties omitted for brevity */
transition: margin .5s;
}
which can be demonstrated below:
Is there something that you are expecting to occur that isn't?

Create small buttons

I'm trying to make a button that's 11px by 11px, but it seems every browser I try has a minimum width of 12px for buttons (except IE9, which does 16px). Is there a way around this or do I need to use anchor tags?
My CSS
#testButton
{
background-image: url(images/Sprites.png);
width: 11px;
height: 11px;
border: 0 none transparent;
}
The Result in IE
Every browser has some default css. try using css reset
try adding padding and margin to 0 in your button css
#testButton
{
background-image: url(images/Sprites.png);
width: 11px;
height: 11px;
border: 0 none transparent;
padding:0;
margin:0;
}
Ok, so interesting question. I've been playing around here. And I'm running Safari on a Mac here.
For me, this works (I think) on a simple <button></button> element:
button {
width: 2px;
height: 2px;
padding: 0px;
box-sizing: border-box;
border: 0;
background: red;
}
I think the important thing to note is the box-sizing parameter. You can get more information about it here. Along with, of course, the padding​ style.

html/css - using sprite with <img> tag - how to remove the outline in Chrome?

I'm redoing a site in which I'm using a CSS sprite. I'm also using the sprite with some tags, which I cannot remove.
So the tag gets a CSS-background-image and appropriate background position. Works fine. I had to remove the alt-attribute, because this kept showing on Firefox. Not nice, but ok.
My problem:
In Chrome I end up having a faint outline around the image. I first thought these were border, but I think it's outline.
If I CSS outline: 3px solid blue the faint border, becomes 3px solid blue... but if I set outline: 0; nothing happens.
More code:
HTML
<img class="ui-li-icon ui-li-thumb iconComments" />
CSS
.ui-icon, .iconComments, .iconMail, .ui-icon-searchfield:after {
background: #FFFFFF /*{global-icon-color}*/;
background: transparent /*{global-icon-disc}*/;
background-image: url(img/sprite.png) /*{global-icon-set}*/;
background-repeat: no-repeat;
-moz-border-radius: 9px;
-webkit-border-radius: 9px;
border-radius: 9px;
}
.iconComments {
background-position: -36px 50%;
}
.iconMail {
background-position: 2px 50%;
}
.iconComments, .iconMail {
height: 20px;
width: 20px;
}
Any idea, where the outline/border is coming from and how to remove it?
Thanks
The issue is likely due to the fact that you do not have a src attribute within your image tag.
If you can absolutely position the image, you can use the sprite directly in the foreground using the CSS clip property.
Usually this is caused by the border attribute. I know you said you think it's outline, but did you try this in your img class...
.imgClass
{
border-style: none;
text-decoration: none;
}
or this
.imgClass
{
border:0;
}

border:none not working on an image set using background

K so I have an image in my html and I am settings its src using css and background: url() the reason for this is because I want to toggle the class on click so that I go back and forth between images. Everything works except for the fact that my image has a border and nothing I do seems to get rid of the stupid thing.
Here is the html:
<img class="minus" />
and here is the css:
.minus{
position: relative;
margin: 0 0 -3px 5px;
float:right;
background: url(/images/mobile/minus.png) no-repeat;
border: none;
display:block;
width: 16px;
height: 16px;
}
I have tried everything I can think of border:0px; border:0; border-width: 0px; border-style:none; anything I could find on here or on the web basicly and nothing will get rid of the stupid border. Any insight would be appreciated.
Edit: using google chrome.
I'm certainly able to reproduce this error in Chrome. Here's a demo:
.minus{
display: block;
margin: 0 0 -3px 5px;
background: url('http://www.google.com/intl/en_com/images/srpr/logo3w.png');
width: 100px;
height: 100px;
}
<img class="minus">
However, w3.org specifies (emphasis mine):
The SRC attribute specifies the URI for the image to be embedded. Its syntax is the same as that of the HREF attribute of the tag. SRC is mandatory.
Setting a CSS background-image is not the same as setting the src HTML attribute of <img>... and perhaps that's your problem. You should consider using a different element, e.g.: a <span>:
.minus {
display: block;
margin: 0 0 -3px 5px;
background: url('http://www.google.com/intl/en_com/images/srpr/logo3w.png');
width: 100px;
height: 100px;
}
<span class="minus"></span>
Here is a fiddle that uses a div with the class (I see no border). When I try an img with the class, it shows nothing (in firefox 7)

CSS3 and PIE not working in IE 8

Im trying to demo CSS3PIE and it wont work in IE at all.
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<link href="test.css" type="text/css" rel="stylesheet">
<title>Test</title>
</head>
<body>
<div id="title"></div>
<div id="sub_title"></div>
<div id="main_area">
<div id="date_area"></div>
</div>
</body>
</html>
css:
body{
margin: 0 auto;
}
#title{
margin: 0 auto;
width: 100%;
height: 40px;
background-color: white;
}
#sub_title{
margin: 0 auto;
width: 100%;
height: 25px;
background-color: green;
}
#date_area{
width: 310px;
height: 250px;
border: 1px solid #4A4949;
padding: 60px 0;
text-align: center;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
-webkit-box-shadow: #707070 2px 2px 4px;
-moz-box-shadow: #707070 2px 2px 4px;
box-shadow: #707070 2px 2px 4px;
background: #EBEBEB;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#EDEBEB), to(#C9C7C8));
background: -moz-linear-gradient(#EDEBEB, #C9C7C8);
background: linear-gradient(#EDEBEB, #C9C7C8);
-pie-background: linear-gradient(#EDEBEB, #C9C7C8);
behavior: url(/PIE.htc);
}
The result is just a block with a border, no gradient/shadow etc
Any help/solution would be much appreciated.
The behavior location should be relative to your HTML file, not your CSS like any other declaration using url(). So assuming your index.html and PIE.htc is in root and your CSS is inside a 'css' folder, you should go like this:
background-image: url(../images/example.jpg);
behavior: url(PIE.htc);
Also, try adding a .htaccess file with the following content in the same location as the PIE.htc file:
AddType text/x-component .htc
Hope this helps.
Try adding
position:relative;
z-index: 0;
as suggested here http://css3pie.com/forum/viewtopic.php?f=3&t=10
This question is similar to the one posted here: CSS3 PIE - Giving IE border-radius support not working?
CSS3 PIE - Giving IE border-radius support not working?
The PIE.htc requests should respond with the mime type "text/x-component" - or IE won't touch the behaviour.
adding: AddType text/x-component .htc - to the .htaccess file worked like a charm for me.
The shorthand CSS property let's you control what corners to round or not.
border-radius: 0 15px 15px 0;/*(top-left, top-right, bottom-right, bottom-left). */
Try to clear cache in your browser. Especialy when you switch between compatibility modes. It really helps
Make sure you have the latest beta release. If the HTC file still causes issues, try the JS implementation.