简体   繁体   English

滚动时不考虑阴影

[英]Shadow is not taken into account when scrolling

In the left part of the following picture you can see an object which has been positioned on the right edge of the container.在下图的左侧,您可以看到一个位于容器右边缘的对象。 Part of the object is cut off according to the overflow property and can be displayed by scrolling horizontally to the right.对象的一部分根据溢出属性被截断,可以通过水平向右滚动显示。

容器右边框的对象,向右滚动前后

In the right part of the picture you can see the object after scrolling to the right.在图片的右侧,您可以在向右滚动后看到该对象。 The shadow on the right edge of the object is cut off.对象右边缘的阴影被切断。 When scrolling, only the extent (width) of the object without the shadow was taken into account.滚动时,只考虑没有阴影的对象的范围(宽度)。

在此处输入图片说明

Setting a margin or padding value for the object did not change the behavior.为对象设置边距或填充值不会改变行为。 Experiments with the css property scrolling-margin or scrolling-padding have also failed.使用 css 属性 scrolling-margin 或 scrolling-padding 的实验也失败了。

The behavior was tested under Chrome (79.0.3945.88), Opera and Edge in the latest versions under Mac OS.该行为在 Mac OS 下最新版本的 Chrome (79.0.3945.88)、Opera 和 Edge 下进行了测试。

I don't want to create another container around the object to create a space.我不想在对象周围创建另一个容器来创建空间。 Is there any other way to avoid cutting off the shadow?有没有其他方法可以避免切断阴影?


The relevant CSS for the container:容器的相关 CSS:

margin: 4px;
box-sizing: border-box;
overflow: auto;

The relevant CSS for the object:对象的相关 CSS:

background: lightgreen;
background-clip: padding-box;
box-sizing: border-box;
border-width: 1px;
border-style: solid;
border-color: darkslategray;
border-radius: 50%;
box-shadow: 2px 2px 4px gray;
position: absolute;

How about this.这个怎么样。 Put something in the ::after of the divs and position that slightly to the right.::after的 div 中放一些东西,然后稍微向右放置。
It sounds like a bit of a kludge, but of all the things I tried, this is the only trick I could get to work.这听起来有点麻烦,但在我尝试过的所有事情中,这是我能开始工作的唯一技巧。

 /* Change line 34 to see the beauty of flex-design ;-) */ body { width: 100vw; height: 100vh; margin: 0; background-color: white; overflow: hidden; display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-content: stretch; align-items: stretch; } nav { box-sizing: border-box; background-color: yellow; opacity: 0.9; display: flex; align-items: center; user-select: none; flex: 0 0 35px; padding: 5px; border-bottom: 4px solid #ddd; } main { box-sizing: border-box; flex: 1 1 auto; align-self: stretch; display: flex; flex-direction: row; /* row, row-reverse, column, column-reverse */ flex-wrap: nowrap; justify-content: flex-start; align-content: stretch; align-items: stretch; } article { --raster: 25px; --raster-color: #ddd; margin: 4px; box-sizing: border-box; overflow: scroll; background-attachment: local; background-image: linear-gradient(var(--raster-color) 1px, transparent 1px), linear-gradient(90deg, var(--raster-color) 1px, transparent 1px), linear-gradient(var(--raster-color) 0.5px, transparent 0.5px), linear-gradient(90deg, var(--raster-color) 0.5px, transparent 0.5px); background-size: var(--raster) var(--raster), var(--raster) var(--raster), 5px 5px, 5px 5px; flex: 3 1 75%; align-self: auto; position: relative; } section { box-sizing: border-box; background-color: #ddd; flex: 0 0 4px; cursor: col-resize; } aside { box-sizing: border-box; background-color: lightgray; overflow: scroll; flex: 1 1 calc(25% + 10px); /* resizing */ align-self: auto; margin: 4px; padding: 5px; } article div { position: absolute; border: 1px solid black; border-radius: 50%; box-shadow: 4px 4px 8px gray; width: 100px; height: 100px; background-color: lightgreen; color: white; } /* Trick goes here */ article div::after { position: absolute; bottom:-8px; right: -8px; display: inline; content: '\\00A0'; } article div:nth-child(1) { left: 500px; top: 50px; } article div:nth-child(2) { left: 350px; top: 10px; } article div:nth-child(3) { left: 175px; top: 125px; }
 <nav> navigation bar </nav> <main> <article> <div> first </div> <div> second </div> <div> third </div> </article> <section></section> <aside> input area </aside> </main>

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

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