简体   繁体   English

在magento cms>页面上添加自定义样式

[英]Add Custom style on magento cms>page

How i can add the custom style to perticular pag in magento like : 我怎样才能在magento中将自定义样式添加到perticular pag中:

I want to know how we can add style tag in page editor 我想知道如何在页面编辑器中添加样式标记

You can add your custom stylesheet for cms page. 您可以为cms页面添加自定义样式表。 just do this in your cms page open design tab and in layout update xml field just add this code 只需在您的cms页面打开设计选项卡和布局更新xml字段中执行此操作,只需添加此代码即可

<reference name="head">
<action method="addCss">
    <stylesheet>css/your.css</stylesheet>
</action>
</reference>

Hope this will help you 希望这个能对您有所帮助

So ran into this same issue, I needed it to allow the customer to adjust a few values with a media query depending on the edits of the content. 因此遇到同样的问题,我需要它允许客户根据内容的编辑使用媒体查询调整一些值。

Simply place empty comments at the start and end of your style and TinyMCE will not add it's own. 只需在样式的开头和结尾放置空注释,TinyMCE就不会添加它自己的注释。

eg: 例如:

<style type="text/css" scoped><!-- -->
   p{color:red;}
<!-- --></style>

This is valid at least with Magento v1.9.1 这至少在Magento v1.9.1中有效

Since adding <style> tag directly is not working, you can use javascript instead. 由于直接添加<style>标签不起作用,您可以使用javascript代替。 If youe theme is using jQuery, you may do it this way (concat the style tag so editor will not mark it as comment): 如果你的主题是使用jQuery,你可以这样做(连接样式标记,以便编辑器不会将其标记为注释):

jQuery('body').append('<sty'+'le>'+'#header{margin:10px 0 0 0;}#morestylehere{display:inline}'+'</sty'+'le>')

Make sure it's enclosed with <script> tags. 确保它附带<script>标签。

单击显示/隐藏编辑器,您将能够直接编辑HTML源代码,以便在那里添加style标记

@Max unfortunatelly, tinyMCE will convert style tags to html comments. @Max不幸的是,tinyMCE会将style标签转换为html评论。 And after each modification of CMS page you should take care of replacing html comments back to style tags - this is not very good approach. 在每次修改CMS页面后,您应该注意将html注释替换回style标记 - 这不是很好的方法。
So, my suggestion is to use specific CMS page class name, that is being added to body tag. 所以,我的建议是使用特定的CMS页面类名称,即添加到body标签。 You can go to your CMS page, and take a look at source code of the page to find this class name. 您可以转到CMS页面,查看页面的源代码以查找此类名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM