How do I add a custom CSS image to the target background behind a given layer of text in Squarespace?

∥☆過路亽.° 提交于 2019-12-12 01:14:56

问题


We are working on customising a website for our client in Squarespace (so that they can manage it on their own).

I've added a CSS style to the background of a layer of text, but it won't show up. I have imported the image to use into Squarespace and I have the URL.
I have also inspected the page element and found the id that I'm wanting to target to.

This is my code:

#yui_3_17_2_5_1465050472193_17704 {
  background-image: url("http://static1.squarespace.com/static/55bed56ee4b04fdc6e0dd0d8/t/5752e43c22482e7d77f53e3b/1465050172750/Share+the+Love+Kids+Club.png")
}

Why does this not add the image I expect?


回答1:


In Squarespace, currently, any ID starting with "yui" can/will change on page refresh. That is because such IDs are dynamically generated. Therefore, you should not rely on them for use in CSS or Javascript.

However, it is currently accepted that block IDs (ID's starting with "block-" do not change as long as the block is not removed or moved in a way that causes it to be removed (such as dragging a text block directly above/below another text block).

Therefore, you should instead locate the block ID of the block to which you want the CSS rule applied. If you need to target with even greater specificity, start with the block ID then add specificity from there. For example:

#block-yui_3_17_2_4_1443109442267_11866 {
    background-image: url("http://static1.squarespace.com/static/55bed56ee4b04fdc6e0dd0d8/t/5752e43c22482e7d77f53e3b/1465050172750/Share+the+Love+Kids+Club.png")
}

If this still doesn't give you enough to get the problem solved, consider adding a link to the page in question, and stating which block/area on the page you want to target.

Additional Information/References:

  • https://answers.squarespace.com/questions/59297/how-do-i-discover-a-block-id.html
  • https://answers.squarespace.com/questions/10450/which-ids-should-i-target-for-my-css.html


来源:https://stackoverflow.com/questions/37631538/how-do-i-add-a-custom-css-image-to-the-target-background-behind-a-given-layer-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!