根据实际图像宽度

时间:2019-06-08 16:55:58

标签: css image

拥有max-width:33%; max-height:2.5in 想要右边距正确= 33%-屏幕上图像的实际宽度+ .5em 用户想要均匀性-左边文本的图片总是相同的宽度

尝试使用calc(),但不知道如何指定图像的实际宽度 问题是html复制(包含)在其中。否则我可以做

BlkL {display:block; width:33%; float left}
BlkR {display:block; width:66%; float right}
...
<div style='clear:both'>
<BlkL><img ...></BlkL><BlkR>... some text ...<BlkR>
</div>

我也懒得使用JAVASCRIPT来计算加载时的所有余量(这可能会很混乱)。

在我有的部分

Blk     {display:block; border-bottom:thin solid DarkBlue; font-family:New Times Roman; text-align:justify; font-size:14pt; padding-right:3px; font-weight:bold; clear:both}
Blk img {float:left;max-width:33%;max-height:2.5in;margin-right:.5em}

复制/包含的代码中的一个实时示例为

<a href='https://www.usatoday.com/story/news/politics/onpolitics/2019/05/25/jon-voight-says-trump-greatest-president-since-abraham-lincoln/1234123001/?fbclid=IwAR1Om7A3QFKdai2KFUiwrPHLTbl_mdfmrwVlkMHx9SpxX_2bUdzPJCSKJcE' target=_blank><Blk><img src='https://www.gannett-cdn.com/presto/2019/01/03/USAT/35e6e01e-0829-482d-b3da-fd5caf8ac2e7-GTY_904690384.JPG' alt='Post'>On Friday night, the actor Jon Voight released a two-partvideo on Twitter calling President Donald Trump &quot;the greatest president since Abraham Lincoln. #AmericanFreedomPressAlliance #USAToday #JonVoight #PresidentTrump</Blk></a>

所需结果:图像左对齐块的前1/3,文本右对齐块的2/3,最小间隔为.5em 实际结果:图片左对齐,但宽度不得超过1/3以便遮挡,文字恰好位于图片的右侧。

0 个答案:

没有答案