html - body 标签不占用所有窗口宽度 +1600px

标签 html css

我有一个应该只显示一半的 div(设计目的),该 div 在 < 1200 像素的屏幕上工作正常,但是当我进入大屏幕时,我的 div 完全显示了,因为 body 没有覆盖所有屏幕

我尝试将 max-width 和 width:100% 设置为 body 但没有成功,我遇到了同样的问题

这是div样式

.testimonials .right-effect{
   border-radius: 81px;
   background-color: #0be881;
   width: 227px;
   height: 152px;
   transform: rotate(-56deg);
   right: -120px;
   bottom: 0;
 }

和体型

body{margin:0}

这是一张图片,蓝色部分是正文,绿色是我的 div

Problem
(来源:gulfupload.com)

最佳答案

Use the CSS3 Viewport-percentage feature. (大众) 和 Calc

这样你就可以像 left: calc(50% - 120px + 50vw);

50% - 120px 将使您的元素居中(我假设 120px 是元素宽度的一半);

+ 50vw 将元素向右移动(- 50vw 将向左移动);

不要忘记您的元素必须是 position: absoluteposition: relative;(相对于 body 或任何其他居中元素)才能起作用。

关于html - body 标签不占用所有窗口宽度 +1600px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53982172/

相关文章:

html - 图像顶部垂直居中的文本

html - 如果使用 courier 字体,反斜杠在 Windows 7 的 IE9 中呈现为 wong 符号 (₩)

javascript - 访问另一个网站时在后台调用网站

html - 使用 CSS 对按钮进行“单击”动画效果

css - Bootstrap 4 Navbar Hover BG 颜色

javascript - 在导航菜单中突出显示当前页面?

c++ - 将 C++ 库链接到 html 前端

javascript - 在 jQuery 中无限改变 z-index

html - 我怎样才能使这个文本 div 居中?

html - 使元素出现在 div 的右侧