html - 在左边缘放置一个垂直的 Bootstrap 按钮

标签 html twitter-bootstrap css bootstrap-4

我想在屏幕的左边缘放置一个垂直的 Bootstrap 按钮。现在我有这个 CSS:

#button1 {
  position: absolute !important;
  z-index: 10 !important;
  left: 0px !important;
  bottom: 20% !important;
  transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  -o-transform: rotate(90deg);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

<button id="button1" class="btn btn-lg btn-danger">Click to toggle popover</button>

问题是它不是一直在左边;如果它没有旋转,那将会是这样,但由于它是旋转的,所以存在空间间隙。我该如何解决这个问题?

最佳答案

transform-origin: bottom left; 添加到您的按钮

#button1 {
  position: absolute !important;
  z-index: 10 !important;
  left: 0px !important;
  bottom: 20% !important;
  transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -webkit-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  transform-origin: bottom left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

<button id="button1" class="btn btn-lg btn-danger">Click to toggle popover</button>

希望这有帮助:)

To learn more about transform-origin property, visit https://www.w3schools.com/cssref/css3_pr_transform-origin.asp

关于html - 在左边缘放置一个垂直的 Bootstrap 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50963542/

相关文章:

html - 与同一行中另一列高度相同的响应图像

javascript - 在浏览器中打开 index.html 时,jQuery 代码不会运行。控制台没有错误

jquery - 如何使用 jQuery 获取 Bootsramp btn-group 的值

css - 强制响应图像调整大小而不是小屏幕上的段落

css - ngClass 不刷新 css 类

internet-explorer - CSS 问题 : Combination of "text-align: center" and "min-width" not working in IE 7/IE 8 compat mode

javascript - 使用bumpbox、mootools.js实现pdf lightbox并确保用户滚动到文档末尾

javascript - 只允许在两种形式中选中一个单选按钮

javascript - 向下滚动加载数据以进行 Bootstrap 模式(延迟加载)

css - IE 和 Chrome 中的不同填充