【问题标题】:Wordpress changing a css value inline in a themeWordpress 在主题中内联更改 css 值
【发布时间】:2014-06-10 12:00:45
【问题描述】:

我正在使用这个 wordpress theme,我需要更改主页上 div 类中的值。 这个 div 类是

<div class="vertical-center">

还有内联值

style="padding-top: 132px;

我试图找到这个值的设置在哪里

  • 使用文本编辑器搜索文件(.js、.css、.php):无
  • 管理员中的主题选项设置:无
  • 进入mysql数据库:无

并且这个值不会出现在源页面中,但是你可以用inspector看到它(使用chrome)

这个值在哪里以及如何改变它??? 谢谢

【问题讨论】:

  • 你联系过作者吗?
  • 虽然这是不好的做法,但您可以在 .vertical-center 选择器中使用 padding-top: 10px !important; 覆盖它。
  • 还没有,没想到这么复杂
  • 如果您在查看源代码时没有看到它,则它正在被某些 JS 应用。 JS 不太可能设置为 132px,而是会计算某物的高度。最简单的解决方法是按照 FDL 的建议使用 CSS 覆盖它。我会看看你的主题,看看我是否能找到原因。
  • @FDL,覆盖哪里?我不知道那个值在哪里

标签: php html wordpress


【解决方案1】:

padding-top 样式正在被您的活动主题文件夹中/javascripts/main.js 中的某些 JavaScript 应用(尊严)。

应用此样式的行是:

 //Vertical Centering of natural content spcific elements (non-images)
 $(function ($) {
          /*if your element is an image then please use $(window).load() instead tha above function wrap, because we want the coding to take
          effect when the image is loaded. */

          //get the width of the parent
          var parent_height = $('.vertical-center').parent().height();
          var image_height = $('.vertical-center').height();

          var top_margin = (parent_height - image_height)/2;

          //center it
          $('.vertical-center').css( 'padding-top' , top_margin);
          //uncomment the following if ithe element to be centered is an image
          $('.vertical-center-img').css( 'margin-top' , top_margin);
   });

如果您想删除它,一种选择是使用 CSS:

.vertical-center {
    padding-top: 0 !important;
}

.vertical-center-img {
    margin-top: 0 !important;
}

通过使用!important,您将覆盖内联样式。

确保您在子主题或适当区域中执行此操作以添加自定义 CSS 以避免在更新主题时被覆盖。

【讨论】:

  • "通过使用 !important 你覆盖了内联样式。"我不知道...谢谢:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-09
相关资源
最近更新 更多