将修复定位设置为子元素 [英] Set fix positioning to a child element

查看:77
本文介绍了将修复定位设置为子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题并且在我的脑海中有这个:

如果一个元素在css中有固定位置它会粘在窗口上并且不会滚动



i有一篇文章的标题和内容如下:



I have a question and have this in my mind:
"if an element has fix position in css it sticks to window and won't scrolled"

i have an article that has a title and contents like this:

<article>
    <h3>Title</h3>
    <p>Content Here</p>
</article>







内容太大,无法放入文章因此,文章元素获取滚动条,

i想要当用户滚动文章时,标题获得修复位置并且不会滚动

并坚持文章的顶部。(使用jquery )



请原谅我的英语不好,我希望我的问题很清楚!




content is too large to fit in article so article element gets scrollbars,
i want when user scrolls the article, the title get fix position and won't scroll
and stick to the top of article.(using jquery)

excuse me for my bad english,i hope my question was clear to you!

推荐答案

为内部

溢出的标签添加样式表属性:滚动;。这可能对你有所帮助。因为如果文章的内容太多而且内容在

add Style sheet property for internal

Tag that overflow:scroll;. this may be helpful to you. because if article has too much large content and if content is inside the

标签内,那么它会显示滚动条&标题仍然存在。

Tag then it will shows the scroll bar & header will be still there.


我为你创建了小提琴。在这里查看

希望你想要同样的事情
I have created fiddle for you.Check it here
Hope you want the same thing


这篇关于将修复定位设置为子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆