html - 固定图像周围有 "border"

标签 html css

嘿,今天我尝试编写一个着陆页代码,但我被卡住了。我试图将图像全屏放置为 60px 的“边框”。现在我想在顶部放置导航栏,在图像左右两侧放置一些垂直文本。 (“边框”中的导航栏和垂直文本)。我该怎么做?

我已经知道那不是正确的做法。

.fullscreen-img {
    background-image: url(../img1);
    height: 100vh;
    width: 100vw;
    background-position: center;
    background-repeat: no-repeat;
    border: 50px solid white;
    background-size: 100% 100%;
    box-sizing: border-box;
    padding: 0px;
    margin: 0px;
}

最佳答案

像这样?或者您是否希望左右文本列一直延伸到标题/导航上方的顶部?

main {
  display: flex;
}

.left,
.right {
  display: flex;
  justify-content: center;
  padding: 5px;
  background-color: tomato;
}

.middle {
  flex: 0 1 80%;
}

nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px;
  background-color: yellow;
}

.hero-container {
  display: flex;
  height: 100vh;
  width: 100%;
  background-color: blue;
}

.hero {
  flex: 0 1 80%;
  padding: 10px;
}
<main>
  <section class="left">
    <p>left text hi</p>
  </section>
  <section class="middle">
    <nav>
      <a>link 1</a>
      <a>link 2</a>
      <a>link 3</a>
    </nav>
    <div class="hero-container">
      <p class="hero">big image here</p>
    </div>
    <footer>
        <p>Footer</p>
    </footer>
  </section>
  <section class="right">
    <p>Dat right text</p>
  </section>
</main>

关于html - 固定图像周围有 "border",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49563239/

相关文章:

javascript - 为什么 Canvas 上下文 drawImage 在 iPhone 上失败

html - 向内部 div 添加边距时,较大 div 内定义宽度的 Div 元素会溢出

css - 如何右对齐 Vue.js 元素导航栏中的链接?

javascript - 实现纯 javascript 轮播。(无插件)

javascript - jquery .off() 与指针事件 : none

javascript - 在 HTML 中显示可编辑列表(如电子表格)的最简单方法是什么?

html - css 最小宽度无法正常工作

html - 有人可以解释为什么 Div 隐藏在 HTML 布局中的其他 Div 后面吗?

javascript - 根据日期更改链接

html - 如何使div高度达到父td的100%