html - 在 CSS 中缩小页面?

标签 html css text href

我正在为自己开发一个介绍网站,但我遇到了一个错误。我使用视频背景,我希望我能保留并仍然解决我的链接问题。

这是问题的屏幕截图:https://gyazo.com/d3f9c4f933f5b54c70835451d62d258f

“Riptide”链接在技术上以页面为中心,但我不希望页面如此宽。如果我最小化页面宽度,链接就会移动。这是我当前的代码:

@import url('https://fonts.googleapis.com/css?family=Raleway');
body {
    max-width: 100%;
}
.fullscreen-bg {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  z-index: -100;
}

.fullscreen-bg__video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

@media (min-aspect-ratio: 16/9) {
  .fullscreen-bg__video {
    height: 300%;
    top: -100%;
  }
}

@media (max-aspect-ratio: 16/9) {
  .fullscreen-bg__video {
    width: 300%;
    left: -100%;
  }
}

@media (max-width: 767px) {
  .fullscreen-bg {
    background: url('../img/videoframe.jpg') center center / cover no-repeat;
  }

  .fullscreen-bg__video {
    display: none;
  }
}

#riptide {
    font-size: 4.5em;
    text-decoration: none;
    font-family: "Raleway", sans-serif;
    font-weight: 900;
    color: white;
    position: relative;
    padding: 15px;
    top: 40%;
    margin-left: 50%;
    margin-right: 50%;
    border-radius: 10px;
    transition: color 0.6s, background-color 0.6s;
}

#riptide:hover {
    color: black;
    background-color: white;
}

最佳答案

现在知道 OP 需要什么,下面就是解决方案。

我们用 <div> 包裹了他的 anchor 并将其绝对定位在页面的中间。这是通过以下方式完成的:

#test{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
}

RIPTIDE 部分简化为:

#riptide {
  font-size: 4.5em;
  text-decoration: none;
  font-family: "Raleway", sans-serif;
  font-weight: 900;
  color: white;
  padding: 15px;
  text-align: center;
  border-radius: 10px;
  transition: color 0.6s, background-color 0.6s;
  height: 100%;
  display: block;
}

Jsfiddle:https://jsfiddle.net/yrscgvek/10/

让我知道发生了什么或提供更多信息。我会尽我所能提供帮助。

关于html - 在 CSS 中缩小页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41351219/

相关文章:

javascript - 如何制作 CSS 调整大小的动画?

html - Clearfix 问题

javascript - 带有文本的 POST 请求

linux - 快速 unix 命令在文件中间显示特定行?

c# - RichTextBox的C#滚动

javascript - 从存储在变量中的 DIV 中删除具有特定 ID 的 DIv

validation - HTML5 国际化

HTML5 canvas drawImage() 不会在 Firefox 上绘制大图像

html - 隐藏在 Bootstrap 中输入后面滚动的文本

javascript - Onload JavaScript 有时不执行