有没有办法让容器溢出到左边?(Is there any way to make a container overflow to the left?)

编程入门 行业动态 更新时间:2024-10-24 21:33:56
没有办法让容器溢出到左边?(Is there any way to make a container overflow to the left?)

真的,与标题相同。 我有两个div,每个宽度为50%。 图像可能最终出现在任何一个图像中,如果右图像太宽,它只会向右溢出。 完善。 但左边的图像也是如此。 不用说,这会扰乱两个div的50/50外观。

那么 - 有没有办法强制溢出到LEFT

谢谢。

HTML:

<div class="container"> <div class="content_1"> <img> </div> <div class="content_1"> <img> </div> </div>

CSS:

.container { width: 100%; max-width: 1100px; } .container > div { width: 50%; } .container_1 { overflow: left /* I know this doesn't exist... yet */ }

Same as the heading, really. I have two divs, each 50% width. An image might end up in either one and if the right image is too wide it simply overflows right. Perfect. But so does the image on the left. Needless to say this messes up the 50/50 appearance of the two divs.

So -- is there any way to force an overflow to the LEFT?

Thanks.

HTML:

<div class="container"> <div class="content_1"> <img> </div> <div class="content_1"> <img> </div> </div>

CSS:

.container { width: 100%; max-width: 1100px; } .container > div { width: 50%; } .container_1 { overflow: left /* I know this doesn't exist... yet */ }

最满意答案

您可以使用css属性direction:rtl强制文本的从右到左的行为,在溢出图像的上下文中给出了它溢出到左侧的印象。

基本示例:

HTML:

<div class="container"> <div class="image image1"><img src="http://placehold.it/800x300"/></div> <div class="image image2"><img src="http://placehold.it/800x300"/></div> </div>

CSS:

* { box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; } .container { width:100%; } .image { width:50%; border:1px solid red; float:left; overflow:auto; } .image1 { direction: ltr; } .image2 { direction: rtl; }

演示: http //jsfiddle.net/n5LyR/1/

You can use the css property direction:rtl to force the right-to-left behaviour of text which in the context of overflowing an image gives the impression that it is being overflowed to the left.

Basic example:

HTML:

<div class="container"> <div class="image image1"><img src="http://placehold.it/800x300"/></div> <div class="image image2"><img src="http://placehold.it/800x300"/></div> </div>

CSS:

* { box-sizing:border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; } .container { width:100%; } .image { width:50%; border:1px solid red; float:left; overflow:auto; } .image1 { direction: ltr; } .image2 { direction: rtl; }

Demonstration: http://jsfiddle.net/n5LyR/1/

更多推荐

本文发布于:2023-04-27 14:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327144.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   容器   container   overflow   left

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!