1

I have been asked to create a READ MORE option for one of our publishing pages on-prem. It works great on my local machine, but can't get it to work in SharePoint. Guessing I am putting my code in the wrong place or entering it wrong.

My code is here: https://jsfiddle.net/DShepherd79/o28xjuwt/

As you can see it works, but not in SharePoint and it should.

Thanks

6
  • Use browser tool and check the CSS are actually getting loaded and they are not getting overridden by SP styles – Amal Hashim Jul 20 '16 at 15:31
  • Please describe your scenario with more detail: Your title mentions both Script Editor and CEWP. How are you using those? Is the HTML being pulled in through linking through the CEWP? Is it entered directly in the CEWP? Is it directly on the publishing page? Where is your CSS, how does that get onto the page? – Dylan Cristy Jul 20 '16 at 15:40
  • Delete your <body> tags... SharePoint pages already have a body. – Erin L Jul 20 '16 at 15:59
  • My html is in the page content and my css is in the script editor using <style> tags before and after my code. Have also tried the same in CEWP and referenced the css using a txt file. – D. Shepherd Jul 20 '16 at 16:08
  • If you use a CEWP to link to a file, it will dump the contents of that file into the page source as if the content were originally on the page. However, in a Script Editor, you can use a <link> to create a regular link to a stylesheet. Maybe try that? – Dylan Cristy Jul 20 '16 at 17:38
1

After much trial and error I finally figured it out. For whatever reason it only worked when the file was saved as .html and linked through the CEWP, but the key was to include ALL the HTML code starting from !doctype html, html, meta, etc.

As for the .css I added that in a script editor with tags and everything worked as it should.

0

If you add the above css to the script editor web part, the :checked css property gets stripped out. If you reference the CSS from an external file, it will work.

2
  • I tried this and it didn't work. Tried doing this with my HTML and CSS and still nothing. Maybe I am doing it wrong? I am new with CSS in SharePoint. – D. Shepherd Jul 20 '16 at 16:10
  • create a style sheet fox ex. custom.css and put it under SiteAssets library. Then refer the style sheet using link src tag within the script editor. If that doesn't work you can always fallback to javascript way of handling Read More (show/hide) – Aveenav Jul 20 '16 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.