html - 将滚动框向下移动到文本框区域?

标签 html css scroll position

我做了一个简单的布局,但我已经好几年没有编码了,我在定位和移动滚动框以与我在此图像上创建的文本框区域对齐时遇到问题。

这是我目前的编码。肯定遗漏了一些东西......

<center>
<div class="img">
    <div class="scroll">
      <a>
         text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here          text here text here text here text here 
      </a>
    </div>
</div>
<style>
   .img{
  background-image: url(http://i65.tinypic.com/4janew.jpg);
  background-size: 100% 100%;
  width: 930px;
  height: 634px;
  text-align: center;
  overflow: hidden;
  padding: 7%;
}


.scroll{
  height: 50%;
  width: 100%;
  overflow-y: auto;
  padding-right: 25%;
}

.scroll a{
position: relative;
bottom: -400px;
  font-size: 14px;
  color: #BBA894;
  font-family: Times New Roman;
}
</style></center>

最佳答案

好吧,我还是有点不清楚,但这是我所拥有的:

.img{
  background-image: url(http://i65.tinypic.com/4janew.jpg);
  background-size: 100% 100%;
  width: 930px;
  height: 634px;
  text-align: center;
  overflow: hidden;
  padding: 7%;
    position: relative;
}


.scroll{
    position: relative;
  height: 50%;
  width: 100%;
  overflow-y: auto;
  padding-right: 25%;
}

.scroll a {
    position: absolute;
    left: 100px;
    right: 100px;
    bottom: 250px;
  font-size: 14px;
  color: #BBA894;
  font-family: Times New Roman;
}

由于图像包含框,您需要做的是将文本居中放置,就像我在以下位置所做的那样:

https://jsfiddle.net/L2saoou8/

如果你想让它滚动,那么只需在文本的包含框上添加一个高度,.scroll 然后溢出:auto。

关于html - 将滚动框向下移动到文本框区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45888586/

相关文章:

css - HTML SVG 如何在鼠标悬停时将元素更改为可见/隐藏?

html - Div 与另一个 Div 重叠

html - 希望横幅和图像看起来像具有相同宽度的单个图像,但应根据所有浏览器尺寸进行响应

javascript - 在嵌套部分的路点上向前和向后更改滚动方向

html - 如何在 CSS 中的 2 个分区上放置 2 个嵌套阴影?

javascript - Div 作为模式 - javascript

javascript - 设置禁用范围输入的样式

css - Content Div 内的 100% Height Div

wpf - 检测FlowDocument更改并滚动

jQuery 滚动条间距问题