html - 如何旋转背景并切出超出设备宽度的部分?
问题描述
所以基本上我想在移动设备上有一个旋转的背景。我试过使用
transform: rotate(15deg);
但是每当我这样做时,身体的宽度就会变大,我尝试过使用类似的东西
overflow: hidden;
但这没有用。所以我想知道如何旋转我的背景/背景颜色。
解决方案
如果您使用此 CSS,它将自动调整查看器的背景以适合他们的屏幕(响应式)
<style>
body {
background-image: url("example.jpg"); /* The image used */
background-color: #cccccc; /* Used if the image is unavailable */
background-position: center; /* Center the image */
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover; /* Resize the background image to cover the entire container */
background-attachment: fixed; /* makes the background position fixed */
}
</style>
<html>
<body>
<!-- put your html here !-->
</body>
</html>
我想这比旋转背景要好,但如果你真的想旋转背景,你可以使用我认为这样的东西。
<style>
body {
background-image: url("example.jpg"); /* The image used */
background-color: #cccccc; /* Used if the image is unavailable */
background-position: center; /* Center the image */
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover; /* Resize the background image to cover the entire container */
background-attachment: fixed; /* makes the background position fixed */
transform: rotate(15deg);
}
</style>
<html>
<body>
<!-- put your html here !-->
</body>
</html>
推荐阅读
- sql - “链接” SQL 命令的问题
- r - 在 ggplot 中具有不同位置的误差线和条形图
- laravel - Laravel 的视频显示问题 - Vuejs
- debian - 由 systemd OnBootSec 触发时 logrotate 未运行
- angular - Angular 6:表单提交因表单未连接而取消
- react-native - 反应原生导航错误“导航未定义”
- java - 在 Postman 上使用 XML 进行 POST 的内部服务器错误
- python - 相同的 4 位数字排列成 2 对
- javascript - 如何将 3 列平均分成 2 列?
- python - 列表中列的 SQLAlchemy 多对一关系查询过滤器