【问题标题】:Content hide/show design tweak内容隐藏/显示设计调整
【发布时间】:2018-08-07 03:26:44
【问题描述】:

我一开始只是隐藏了 wordpress 主页的内容,并在单击按钮时显示。但是当显示内容时,由于扩大了 div,设计会变得混乱。请查看网站 - iamicongroup.com

if (! sessionStorage.firstVisit) {
// hide the element
$("#content").hide();

// check this flag for escaping this if block next time
sessionStorage.firstVisit = "1";
}
$(".roll-button").click(function(){
$("#content").show();
});

【问题讨论】:

  • jQuery 不对此负责——问题出在 CSS 上。
  • "siteorigin-panels-stretch panel-row-style panel-row-style-for-8-0" 对于这个 div 边距和填充的应用量很大,请调试它,你做到了jquery 中的一些东西,在调整大小时它工作正常
  • 问题是<div class'siteorigin-panels-stretch'> 内部的<div class 'panel-grid panel-has-style'> 将大量填充作为内联样式。在调整大小时,它会调整为正确的填充。如果您愿意,可以通过覆盖样式 .panel-grid.panel-has-style > div { width: 100%; padding: 100px 80px !important; } 对填充进行硬编码

标签: javascript jquery css wordpress


【解决方案1】:

尝试使用 transform 和 height 属性来隐藏它,而不是显示隐藏:

if (! sessionStorage.firstVisit) {
  $("#content").css({'transform':'scaleY(0)','height':0});
  sessionStorage.firstVisit = "1";
}

$(".roll-button").click(function(){
  $("#content").css({'transform':'scaleY(1)','height':'auto'});
});

【讨论】:

  • 嗨 Sushil,感谢您的及时回复。不幸的是,单击按钮后内容宽度变小了。查看屏幕截图 - imgur.com/a/0dlBvuj
  • 尝试使用 scaleY 而不是 scaleX。不确定它是否有效。问题是由于 javascript 的一些内联样式造成的。
  • 哇 Sushil,使用 scaleY 完全解决了设计故障。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-08
  • 1970-01-01
  • 2019-03-18
  • 1970-01-01
  • 1970-01-01
  • 2017-05-01
相关资源
最近更新 更多