Sharepoint 2010 + CSS3Pie isn't working because off behavior and specified url
Asked Answered
M

7

6

I'm branding a new Sharepoint 2010 public facing website. In this website I want to use shadows and rounded corners around several containers. I first tried to do it myself, but a colleague of mine told me about CSS3Pie (http://css3pie.com), which works really nice.

The problem I'm experiencing is specifying the path of the HTC-file. At the moment I've got this:

#left_content_small
{
    width: 610px;
    padding: 20px;
    border: 1px solid #999;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    -moz-box-shadow: 10px 10px 5px #888;
    -webkit-box-shadow: 10px 10px 5px #888;
    box-shadow: 10px 10px 5px #888;
    behavior: url(/PIE.htc);
}

This isn't working properly in IE. Also, using

    behavior: url(Style Library/StyleSheets/PIE.htc);

isn't working either. Also, placing " or ' around the string doesn't work. However, specifying the behavior URL like this:

behavior: url(_layouts/PIE.htc);

does work. All containers are now rendered correctly.

I could place the htc-file in the layouts folder, but I prefer not to as it kind of corrupts the default Sharepoint folders with custom files.

I've checked the page loading with Fiddler and I see the PIE.htc file returning a 200-code (which is good) in all cases. It doesn't matter if I place it in the layouts, style library or root of the site, every time it's returning a 200.

There are some known issues with CSS3Pie: http://css3pie.com/documentation/known-issues/ which state something about relative url's and such. I thought I've nailed it by placing a /-character in front of the url. Also tried the full domain url (http://testsite.local/PIE.htc), but that isn't working properly either.

Any ideas of how to place the htc file somewhere in the Sharepoint 2010 site and not in the layouts folder?

Mailand answered 23/11, 2010 at 12:18 Comment(1)
As I'm not working on SharePoint projects for the past couple of months/years I can't confirm a specific answer. If someone can tell me if one of the comments contains the right answer, I'll be happy to mark it.Mailand
R
8

When working with .htc files and SharePoint 2010 (and any version of IE after IE7), you must either be in Permissive File mode or add the "text/x-component" MIME type to the AllowedInlineDownloadedMimeTypes list for each web application using PIE.

Permissive mode is the easiest to set on a web app but also opens you up to potential exploits if you allow users to upload content. (This is the same reason why PDFs do not open inside your browser by default in SharePoint 2010)

If this MIME type is not allowed, then IE will download the .htc but it will refuse to execute any behaviors contained in the file (the file is sent with the "X-Download-Options:noopen" header).

Adding the mime type to the webapp is relatively simple via PowerShell.

$webapp = Get-SPWebApplication <name or URL of web app>
$webapp.AllowedInlineDownloadedMimeTypes.Add("text/x-component")
$webapp.Update()

This is a per-webapp setting, so you will need to make the change to each webapp that will use PIE.

Making this change will also let you store the PIE.htc inside a document library.

-Robert

Rustie answered 5/7, 2012 at 22:11 Comment(2)
This is the correct answer, as the issue above isn't necessarily caused by relative URLs but simply by how the file is handled when it is located in "_layouts/" instead of "/style library/".Masquer
This is the correct answer and should be marked appropriately.Sundry
C
3

I had the same issue and fixed it with the pie.js file:

$(document).ready(function (event) {
    var webparts = $('.s4-wpTopTable, .ms-WPSelected');
        $.each(webparts, function(index,webpart)
        {
            $(webpart).wrap("<div class=\"webpart rounded\" />");
        });

    Modernizr.load({
        test: Modernizr.borderradius,
        nope: '/siteassets/js/pie.js',
        complete: borderradiusComplete
    });
});


function borderradiusComplete()
{
    if (window.PIE && !Modernizr.borderradius) {
        $('.rounded, .bottomrounded').each(function() {
            PIE.attach(this);
        });
    }
}

and then in my css:

.borderradius .webpart.rounded
{ 
border-radius:5px 5px 5px 5px;
-khtml-border-radius:5px 5px 5px 5px;
-webkit-border-radius:5px 5px 5px 5px;
-moz-border-radius:5px 5px 5px 5px
}
.no-borderradius .webpart.rounded
{
position:relative;
border-radius:10px 10px 10px 10px;
}

hope anyone benefits from this. if your box dissappears when you go into edit mode, you need to work with position:relative as described in the earlier above. this works on Sharepoint 2010 and Office365 Sharepoint Online

Consalve answered 14/6, 2011 at 8:53 Comment(1)
Thanks! I'm not on the project anymore so can't test it out, but upvoted it anyways. It does look alright.Mailand
L
1

i had the same problem with a sharepoint 2010 branding and i fix with the css3pie js version.

1 you need to add the jquery path on your master page. < script type="text/javascript" src="/Scripts/jquery-1.6.2.min.js" > < /script >

2 add pie.js script on your master page < script type="text/javascript" src="/Scripts/PIE.js" >< / script >

3 you need to create a jsfunction to attach the pie. on your master page < script type="text/javascript" > $(function() { if (window.PIE) { // the name of your element has the class="rounded" $('.rounded').each(function() { PIE.attach(this); }); } });

4 Save and Publish your master page and Scripts

Lilybel answered 10/8, 2011 at 17:49 Comment(0)
P
1

It seems that the PIE.htc file will only be recognized and rendered from a virtual directory like _layouts. I tried every variation from a non virtual directory.

Purpure answered 22/5, 2012 at 15:33 Comment(0)
E
1

I used the PIE.htc file for border-radius to apply it on img element on *.aspx page in SharePoint 2010 environment. Any of the url combinations both relative and absolute did not work for me. For example none of the following worked:

bahavior: url(http://[root]/[path]/PIE.htc); 
behavior: url(/[path]/PIE.htc);
behavior: url(../[path]/PIE.htc);  
behavior: url([path]/PIE.htc); 

The PIE.htc file worked only when it was placed in the same folder as the *.aspx file. i.e bahavior: url(PIE.htc). After trying different url combinations with single quote and double quotes (both relative and absolute paths), I was finally able to get it work by using the uncompressed version of the file "PIE_uncompressed.htc". No matter there is single quote, double quote or no quote, it worked for me for both absolute and relative paths when I used the uncompressed file. Therefore, any relative or absolute path worked fine with the uncompressed file. I also have to add position:relative in the CSS as shown below:

img.homePageButton
{
 position:relative;
 border-radius: 25px;
 behavior: url(/[path]/PIE_uncompressed.htc);
}

The above CSS worked fine and the image was properly styled with border-radius in IE8.
Note: Relative paths should be relative to the *.aspx file not the CSS file. You can also use a url path relative to the root site.

Extremity answered 24/4, 2018 at 18:24 Comment(3)
You are aware of the fact that the answer is 8 years old? Also, indent the code properly, here is the documentation about markdown: Markdown editing help. I can't say anything about the content of the answer, I'm not all that interested in all this CSS stuff. I'm also not the one who downvoted.Each
Yes, I am aware that the question and the answers are too old. I was searching for solution and I tried all options and did not work for me. I spent a lot of time to get the border radius work on my SharePoint 2010 page. I posted this answer because it worked without issue and it is also very simple. It can work for others with the same issue and I hope it will save their time.Extremity
Just to avoid any misunderstanding: answering old questions is not discouraged. The downvote was probably because of formatting... (+1)Each
A
0

See if the information on this question is helpful:

CSS3 PIE - Giving IE border-radius support not working?

I think this answer may be useful, but you may find good info in other answers as well.

CSS3 PIE - Giving IE border-radius support not working?

Automate answered 14/1, 2011 at 14:52 Comment(0)
F
0

Using an absolute path seems to work fine in most cases with SP2010. We reference it in our SharePoint solutions like so, without any problems:

.yourPIEEnhancedClass {
    behavior: url('/_layouts/ProjectName/Styles/PIE.htc');
}

If you're pointing at the Style Library for whatever reason, the space in the string will probably force you to have to use a quoted string for the behaviour URL... same goes for most things in CSS (e.g. font names with spaces).

The only other thing I can think of is to make sure that IIS is serving up the correct mime-type (text/x-component) for the .HTC. You may have to add it in there manually as per the known issues documentation.

Francefrancene answered 20/6, 2011 at 2:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.