简体   繁体   English

我的div之间的间隔不适用于float和margin

[英]My space between div doesn't work with float and margin

I have two divs like this: 我有两个这样的div:

First div : 第一格:

 <div class="col-md-6" id="owner_name_76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" style="visibility: visible;float:left;margin-left:2px"> <div class="container-fluid"> <div class="row"> <span class="user" style="color:#000a75;font-weight:bold">Général</span> </div> </div> </div> 

Second div : 第二个div:

 <div class="col-md-2 px-4 chevron-down collapsed" data-toggle="collapse" data-target="#76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" aria-expanded="false" style="float:right;margin-right:2px"> <i class="material-icons float-right material-expand ripple" style="color: #0047FD !important;margin-right:2px">expand_more</i> </div> 

This two div are in : 这两个div位于:

 <a class="mdc-list-item" data-placement="top" title="Acceuil" style="cursor:pointer;width:400px;margin-left:4px;margin-right:0em" data-toggle="collapse" data-target="#76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a"> <div class="col-md-6" id="owner_name_76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" style="visibility: visible;float:left;margin-left:2px"> <div class="container-fluid"> <div class="row"> <span class="user" style="color:#000a75;font-weight:bold">Général</span> </div> </div> </div> <!--Collaspe zone--> <div class="col-md-2 px-4 chevron-down collapsed" data-toggle="collapse" data-target="#76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" aria-expanded="false" style="float:right;margin-right:2px"> <i class="material-icons float-right material-expand ripple" style="color: #0047FD !important;margin-right:2px">expand_more</i> </div> </a> 

Here what it looks like : 这里看起来像:

在此处输入图片说明

I want the space between the div to be greater than this , so i have tried with float and with margin but i have the same problem. 我希望div之间的间距大于此间距,所以我尝试了float和margin,但是我遇到了同样的问题。

So i want the icon of expand more to be in the right margin 0 now it is in the center. 因此,我希望扩展更多的图标位于右边缘0,现在位于中心。

I think your codes is not completely posted here, so we have a difference in viewing. 我认为您的代码未完全在此处发布,因此我们在查看方式上有所不同。 But I see in your codes, the width has been set as fixed value 400px . 但我在您的代码中看到,宽度已设置为固定值400px That's why the icon could not move to right. 这就是为什么图标无法向右移动的原因。 Please remove the width:400px; 请移除width:400px; in the a tag. a标签。

Maybe when you run code at your side, the a tag has been set display: block/inline-block .etc.. So you can see it can not move to right. 也许当您在旁边运行代码时,已经设置了a标签display: block/inline-block .etc..因此您可以看到它不能向右移动。 That why we can not understand what you want. 那就是为什么我们无法理解您想要什么。

Something like this? 像这样吗 I need more details. 我需要更多细节。
Just used d-flex from bootstrap. 刚刚从引导程序中使用了d-flex。

 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous"> <!-- just to show it whit boostrap --> <a class="mdc-list-item" data-placement="top" title="Acceuil" style="cursor:pointer;" data-toggle="collapse" data-target="#76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a"> <div class="d-flex" id="owner_name_76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" style="visibility: visible;"> <div> <span class="user" style="color:#000a75;font-weight:bold">Général</span> </div> <!--Collaspe zone--> <div class="ml-auto px-4 chevron-down collapsed" data-toggle="collapse" data-target="#76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" aria-expanded="false"> <i class="material-icons float-right material-expand ripple" style="color: #0047FD !important;margin-right:2px">expand_more</i> </div> </div> </a> 

My problem was solved ! 我的问题解决了! i followed this exemple 我遵循了这个例子

 <div class="container"> <div class="row"> <div class="col-sm"> <div class="row"> <span class="user" style="color:#000a75;font-weight:bold">Général</span> </div> </div> <div class="col-sm"> <div class="col-md-2 px-4 chevron-down collapsed" data-toggle="collapse" data-target="#76a62a154a220a104a16a203a196a25a92a71a58a216a222a172a64a" aria-expanded="false" style="float:right;margin-right:2px"> <i class="material-icons float-right material-expand ripple" style="color: #0047FD !important;margin-right:2px">expand_more</i> </div> </div> </div> </div> 

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

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