【问题标题】:Accordion (html and css only) works on Chrome but not on Edge & MozillaAccordion(仅限 html 和 css)适用于 Chrome,但不适用于 Edge 和 Mozilla
【发布时间】:2020-03-03 15:14:41
【问题描述】:

我正在做一个项目,我使用的是我在这个网站上制作的手风琴:https://accordionslider.com/

它在 Chrome 上完美运行,但在 Firefox 和 Edge 上却不行,当我使用我的自定义导航栏时,我的导航栏和我的其余内容之间只有一个差距。当我使用默认的网站时,我在它应该在的中间有一条细线。您可以使用我提供的网站的 HTML/CSS 进行测试

信息:

  • Mozilla 火狐:73.0
  • 谷歌浏览器:80.0
  • Microsoft Edge:44

我正在使用 Angular,但我认为它没有任何影响,因为这是一个 CSS/HTML 问题

.accordion {
  box-sizing: border-box;
  display: flex;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
  width: 100%;
}

.accordion-select {
  cursor: pointer;
  margin: 0;
  opacity: 0;
  z-index: 1;
}

.accordion-title {
  position: relative;
}

.accordion-title:not(:nth-last-child(2))::after {
  border: 1px solid transparent;
  bottom: 0;
  content: '';
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.accordion-title span {
  bottom: 0px;
  box-sizing: border-box;
  display: block;
  position: absolute;
  white-space: nowrap;
  width: 100%;
}

.accordion-content {
  box-sizing: border-box;
  overflow: auto;
  position: relative;
  transition: margin 0.3s ease 0.1s;
}

.accordion-select:checked+.accordion-title+.accordion-content {
  margin-bottom: 0;
  margin-right: 0;
}


/* Generated styles starts here */

.accordion {
  border-color: #dedede;
  border-radius: 8px;
  border-style: solid;
  border-width: 1px;
  flex-direction: column;
  height: auto;
}

.accordion-title,
.accordion-select {
  background-color: #ffffff;
  color: #7f8787;
  width: 100%;
  height: 65px;
  font-size: 15px;
}

.accordion-select {
  margin-bottom: -65px;
  margin-right: 0;
}

.accordion-title:not(:nth-last-child(2))::after {
  border-bottom-color: rgb(234, 234, 234);
  border-right-color: transparent;
}

.accordion-select:hover+.accordion-title,
.accordion-select:checked+.accordion-title {
  background-color: #ffffff;
}

.accordion-title span {
  transform: rotate(0deg);
  -ms-writing-mode: lr-tb;
  filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0);
  padding-left: 33px;
  padding-right: 33px;
  line-height: 65px;
}

.accordion-content {
  background-color: #f7f7f7;
  color: #7f8787;
  height: 280px;
  margin-bottom: -280px;
  margin-right: 0;
  padding: 30px;
  width: 100%;
}
<div class="accordion">
  <input type="radio" name="select" class="accordion-select" checked />
  <div class="accordion-title"><span>Title</span></div>
  <div class="accordion-content">Content</div>
  <input type="radio" name="select" class="accordion-select" />
  <div class="accordion-title"><span>Title</span></div>
  <div class="accordion-content">Content</div>
  <input type="radio" name="select" class="accordion-select" />
  <div class="accordion-title"><span>Title</span></div>
  <div class="accordion-content">Content</div>
</div>

【问题讨论】:

  • 请将您的代码添加为minimal reproducible example
  • 你能在 JSFiddle 中重新创建吗?
  • 谢谢@Pilum。 JSFiddle 示例在 Chrome、Firefox 和 Edge 中对我有用。与您相同的浏览器版本,除了 Edge 是 44.1。
  • 您能否显示屏幕截图或此代码在您的浏览器中无法正常执行的内容?我复制并粘贴了您的代码和网站的代码,它们在 Chrome、Edge Chromium 和 Firefox 中都运行良好。任何地方都没有问题。

标签: html css firefox microsoft-edge


【解决方案1】:

我使用 MS Edge、Google Chrome 和 Firefox 浏览器测试了您的代码。根据我的测试结果,我发现所有 3 个浏览器都显示相似的输出。我在输出中找不到任何差异或问题。

这是我的测试结果:

如果您仍然面临这个问题,那么我建议您尝试提供更多有关它的信息。我们将再次尝试检查问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    • 2011-02-12
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    • 2023-01-14
    相关资源
    最近更新 更多