Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modal 内容里select位置错乱 #5395

Closed
wangyazhen opened this issue Mar 20, 2017 · 20 comments
Closed

modal 内容里select位置错乱 #5395

wangyazhen opened this issue Mar 20, 2017 · 20 comments

Comments

@wangyazhen
Copy link

Modal 弹出后我能通过什么方法来给html添加overflow: hidden 防止页面滚动
目前只是给body 添加了overflow: hidden 但是页面内容还是可以滚动的.

modal中如果有select 就会导致位置错乱.

Hope to answer as soon as possible, will be appreciated .

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

I am no sure what your problem is? Could you provide a re-producible demo to help us, by forking and editing this codepen: http://codepen.io/benjycui/pen/KgPZrE?editors=001

(A good and minimum codpen will save a lot of time 😃)

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

It will be better if you read smart questions(提问的智慧).

@wangyazhen
Copy link
Author

codepan 地址: demo
正常时候:
image

出现的问题:
image

@wangyazhen
Copy link
Author

Environment(required)

  • antd version: 2.8.0
  • OS and its version: win 10
  • Browser and its version: chrome 56.0.2924.87

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

弹出后我能通过什么方法来给html添加overflow: hidden 防止页面滚动
目前只是给body 添加了overflow: hidden 但是页面内容还是可以滚动的.

modal中如果有select 就会导致位置错乱.

这是两个问题还是同一个问题?

@wangyazhen
Copy link
Author

是一个问题,
因为我发现位置错乱是因为页面还能滑动,

如果给html加上overflow: hidden 不让它滚动就可以解决这个问题了
但我不知道应该用什么方法给html加样式

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

https://ant.design/components/select-cn/#API

看看 getPopupContainer

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

ref #3487

@wangyazhen
Copy link
Author

那如果弹出modal后 怎么不让html滚动
这算一个新的问题了吧 是否要 new issue

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

就在这里讨论即可。

html 会滚动一般是全局样式没设好,看看能否在 codepen 里重现出来?

@wangyazhen
Copy link
Author

在刚才的那个code demo中 滑动鼠标轮 可以看到 antd version的滚动

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

我这里没有出现滚动条,你能录制一个 gif 看看么?

image

@wangyazhen
Copy link
Author

没有滚动条, 但是可以滑动, 就转动鼠标轮就能看到了

t

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

找了一个鼠标还是没重现出来.. 😓

另外这段代码是参考自 bootstrap:http://getbootstrap.com/javascript/#modals 它也没有给 html 去加 overflow: hidden。按目前的信息我暂时不确定是 html 标签的问题。

@wangyazhen
Copy link
Author

这个问题不是bug, 我想问的是怎么通过一个比较优雅点的方法, 比如监听modal弹出事件 来做给html标签添加样式去掉样式的这个事情

t

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

visible 是你控制的,在 visible 被 setState 时去操作 dom 即可。

@wangyazhen
Copy link
Author

我这么想过, 但是我有好几个modal的 不能在每个地方都去操作吧 .

@afc163
Copy link
Member

afc163 commented Mar 20, 2017

封装一个 Modal 来调用。

这个问题看上去很奇怪,我找台 windows 机器试试,感觉滚动条不应该出现。

@wangyazhen
Copy link
Author

谢谢你的耐心解答, 祝 ant-design 越来越好 💯

@lock
Copy link

lock bot commented May 1, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants