【发布时间】:2019-07-28 19:14:26
【问题描述】:
我有两个兄弟 div。一个占据父级的 70% 的宽度并浮动到左侧。它有一个clip-path 来创建一个不规则的多边形。同级 div 的宽度为父级的 100%。我在浮动 div 上放置了一个 shape-outside 属性,以允许同级中的文本以遵循多边形对角线的方式换行。
我无法解决的问题是非浮动兄弟中的文本是动态的,可以是单行或多行。我想确保文本在非浮动 div 中保持垂直居中,并遵循shape-outside 行。
Flex、网格和表格似乎破坏了文本跟随shape-outside 行的能力。 Here is a link to a code pen with what is currently set up.
main {
height: 25rem;
width: 95vw;
margin: auto;
}
#main-left {
background-image: url('https://drive.google.com/uc?id=1NeUyxUgp7I56mTpmzYIUXbQilRnd0dAK');
background-size: cover;
background-position: center;
width: 75%;
height: 100%;
float: left;
-webkit-clip-path: polygon(0 0, 95% 0, 50% 100%, 0% 100%);
clip-path: polygon(0 0, 95% 0, 50% 100%, 0% 100%);
shape-outside: polygon(0 0, 97% 0, 50% 100%, 0% 100%);
}
#main-right {
width: 100%;
height: 100%;
}
<main>
<div id="main-left"></div>
<div id="main-right">
<p>Play with the angles. This is unplanned it really just happens. A fan brush is a fantastic piece of equipment. Use it. Make friends with it. We have no limits to our world. We're only limited by our imagination. The very fact that you're aware of
suffering is enough reason to be overjoyed that you're alive and can experience it. We don't have anything but happy trees here. This painting comes right out of your heart. Any little thing can be your friend if you let it be. Learn when to stop.
You can create beautiful things - but you have to see them in your mind first. There's not a thing in the world wrong with washing your brush. These little son of a guns hide in your brush and you just have to push them out.</p>
</div>
</main>
【问题讨论】:
标签: html css css-float vertical-alignment