简体   繁体   English

CSS多层手风琴菜单—指针和图标

[英]CSS Multi-Level Accordion Menu — Pointer & Icon

https://codyhouse.co/demo/multi-level-accordion-menu/index.html https://codyhouse.co/demo/multi-level-accordion-menu/index.html

I used the above example to build my large, multi-level accordion menu for a mobile website. 我使用上面的示例为移动网站构建了大型多层手风琴菜单。

Everything went well but when I reduced the left margins of the menu items, a ">" pointer, that turns 90% when open, and an icon of a folder got crammed over the text of the menu items. 一切正常,但是当我减小菜单项的左边距时,一个“>”指针在打开时变成90%,并且文件夹图标塞满了菜单项的文本。

I want to be able to reduce the left margins of the pointers and delete the folder icon. 我希望能够减少指针的左边距并删除文件夹图标。

Page after updating with problem: superimposed pointer and icon 问题更新后的页面:指针和图标重叠

Page before changing the margins and colors 更改页边距和颜色之前的页面

UPDATE 更新

Here's a starting point. 这是一个起点。 I'm not going to complete the code for you. 我不会为您完成代码。 You should be able to figure out the rest from here. 您应该可以从这里找出其余的内容。 You can right click, inspect element, then play around with the CSS instead of going back and forth between the page and your code (this will not save so remember to copy it over to your code). 您可以右键单击,检查元素,然后使用CSS来代替在页面和代码之间来回移动(这不会保存,因此请记住将其复制到代码中)。

Add background: none to the following: 添加background: none

Remove Menu folder: 删除菜单文件夹:

.cd-accordion-menu input[type=checkbox]:checked + label::after {
    background-position: -32px 0;
    background: none;
}

Remove Home folder: 删除主文件夹:

@media only screen and (min-width: 600px)
style.css:215
.cd-accordion-menu ul label::after, .cd-accordion-menu ul a::after {
    /* left: 65px; */
    background: none;
}

Remove label folders: 删除标签文件夹:

@media only screen and (min-width: 600px)
style.css:215
.cd-accordion-menu ul label::after, .cd-accordion-menu ul a::after {
    /* left: 65px; */
    background: none;
}

Remove left positioning for label icons: 删除标签图标的左侧位置:

@media only screen and (min-width: 600px)
style.css:211
.cd-accordion-menu ul label::before {
    left: 65px;
}

You reduce the "margin" by removing padding-left from the following CSS: 您可以通过删除以下CSS的padding-left来减少“边距”:

@media only screen and (min-width: 600px)
style.css:206
.cd-accordion-menu ul label, .cd-accordion-menu ul a {
    padding-left: 60px;
}

Reduce padding from 60 to 40 in the following CSS: 在以下CSS中将填充从60减少到40:

@media only screen and (min-width: 600px)
style.css:208
.cd-accordion-menu ul label, .cd-accordion-menu ul a {
    padding-left: 40px;
}

Here's how it looks: 外观如下:

在此处输入图片说明

The chevron and folder are in the :before and :after pseudo-elements respectively. V型和文件夹分别位于:before:after伪元素中。 They are absolutely positioned. 他们是绝对的位置。 The inner component before had enough padding that the body text started after the icons. 之前的内部组件具有足够的填充,以使正文在图标之后开始。 You removed the left padding so that was no longer the case. 您删除了左填充,不再是这种情况。 Since they aren't in document flow the will not be affected by a change in padding. 由于它们不在文档流中,因此不会受到填充更改的影响。

In my opinion, you should build components like this your self since any level of customization will require almost as much work digging into someone else code, without any guaranty that it's well written. 在我看来,您应该自己构建这样的组件,因为任何级别的自定义都需要花费大量的工作来挖掘其他人的代码,而没有任何保证它编写得很好。

If you want to just get rid of the icons set 如果您只想摆脱设置的图标

   .cd-accordion-menu label::before, 
   .cd-accordion-menu label::after {
      content: none;
   }

It looks like the css you're using is responsive so make sure to test on different screen sizes or remove the media queries. 您所使用的css看起来像是响应式的,因此请确保在不同的屏幕尺寸上进行测试或删除媒体查询。 It probably will look fine on your screen but not on everyone's. 它可能会在您的屏幕上看起来不错,但在所有人的屏幕上看起来并不好。

Also fyi padding vs margin aren't synonyms make sure to use the one you mean. 另外,fyi padding vs margin并不是同义词,请确保使用您的意思。 If you don't know you should read up on the box-model 如果您不知道,则应该阅读盒装模型

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

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