简体   繁体   English

如果我们有极长的水平滚动页面,如何在最后一个元素的末尾添加边距/填充,即空间?

[英]How to add margin/padding i.e space right to the end of the last element if we have extremely long horizontal scrolling page?

How to add some space to the right of last element ie in our case after 20th box of 100px*100px aligned right to each other.如何在最后一个元素的右侧添加一些空间,即在我们的例子中,在第 20 个 100px*100px 的框相互对齐之后。 jsfiddle jsfiddle

html html

<div class="container">
  <div class="element" v-for="element in 20" :key="element">{{ element }}</div>
</div>

css css

.container {
  display: flex;
  flex-direction: row;
  padding-right: 50px;   // not working
  margin-right: 50px;    // not working
}

.element {
  margin: 16px;
  min-width: 100px;
  height: 100px;
  background-color: #ddd;
  border-radius: 10px;
}

I added a我添加了一个

display: inline-flex;

to.container and then it works to.container 然后它就可以工作了

You can see it here: https://jsfiddle.net/q2f6710x/4/你可以在这里看到它: https://jsfiddle.net/q2f6710x/4/

And you can add a你可以添加一个

overflow: auto;

to #app到#app

to make it scrollable: https://jsfiddle.net/2uex398f/使其可滚动: https://jsfiddle.net/2uex398f/

Try to add to your container class also justify-content:center.尝试添加到您的容器 class 也 justify-content:center。

.container {
  display: flex;
  flex-direction: row;
  justify-content:center;
}

You can always add bootstrap to you're code through,您可以随时将引导程序添加到您的代码中,

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>

Or at this website https://getbootstrap.com/docs/4.3/getting-started/download/或者在这个网站上https://getbootstrap.com/docs/4.3/getting-started/download/

If you add bootstrap you can use classes such as如果添加引导程序,则可以使用诸如

class="mr-1"

or或者

class="pr-1"

where 1 can be replaced by any number to increase padding or margin其中 1 可以替换为任意数字以增加填充或边距

you can also keep all prior styling.您还可以保留所有先前的样式。

Did you try marking those properties as important?您是否尝试将这些属性标记为重要?

.container {
  display: flex;
  flex-direction: row;
  padding-right: 50px !important;   // not working
  margin-right: 50px !important;    // not working
}

暂无
暂无

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

相关问题 element.setAttibute()方法如何使其在IE中工作? - element.setAttibute() method how to make it work in I.E? 我想刷新我的 html 页面上可用的所有 div,即按标签,我有 2 个代码如何 imerge - i want to refresh my all div available on my html page i.e by tag and i have 2 codes how can imerge Eclipse JavaScript格式化程序疯狂(即:填充太多) - Eclipse JavaScript formatter crazy (i.e: too much padding) 我有大量来自服务器的行数据。 如何在新页面(即重定向页面)上显示此数据? - I have a large number of row data coming in from server. How do I display this data on a new page(i.e Redirected Page)? 当我们单击表中的每一行时如何重定向到不同的URL,即单击每一行元素必须重定向到不同的URL? - How to redirect to different URLs when we click on each row in the table i.e, click on each row element must redirect to different URLs? 在IE浏览器上选择下拉显示隐藏(添加删除元素) - Select drop down show hide (add remove element)on I.E Browser 滚动时的IE CSS位置问题 - I.E css position problem when scrolling 如何针对跨度具有一致的边距/填充? - How to have consistent margin/padding against a span? 为重复活动的开始时间添加持续时间,以便结束时间始终是同一时间(即下午2点至下午4点) - Add a duration to a repeating event's start time so that it's end is always the same time (i.e 2pm to 4 pm) 如何在使用“全选”运算符(即“ *”)和jquery时获得点击元素? - how to get clicked element while using “select all” operator i.e “ * ” using jquery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM