有人能告诉我为什么我的按钮不会调整大小?
无论我将它们设置为我用于按钮的 DIV,都不会调整大小。 我正在上传正确的文件,并且它在服务器上发生了更改,但无论我刷新多少次都没有发生任何事情。 我会删除该网址,这样一旦我得到答案就不能将其用作广告。
[已删除网址]
No matter what I set them to my DIVs I use for buttons don't resize. I'm uploading the correct file, and it has the change on the server, but nothing is happening no matter how much I refresh. I'll delete the URL so this can't be used as advertising once I get an answer.
[removed url]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里的问题是您正在尝试调整内联元素的大小,而这是无法明确控制的。 为了设置元素的高度和宽度,您需要将其显示模式设置为“块”并使用浮动水平对齐元素。
此外,您还需要按照您希望从左到右显示的相反顺序重新排列 DIV。 CSS2 中有一个名为“inline-block”的显示属性,旨在纠正此问题,但并未得到普遍支持。
The issue here is that you're trying to resize inline elements, which cannot be explicitly controlled. In order to set the height and width of the element, you need to set it's display mode to "block" and use float to align the elements horizontally.
Also, you'll need to rearrange your DIVs in the reverse order you'd like them to be displayed left-to-right. There is display property in CSS2 called "inline-block" which is designed to correct this, but it's not universally supported.
在 CSS 中,具有 display: inline 的元素不能应用 宽度 或 高度。 为此,您需要 display: inline-block 。 如果您给任何内联元素指定宽度或高度,IE 会错误地将它们转换为内联块。 幸运的是,自从 Firefox 3 发布以来,您只需最少的黑客攻击就可以使用内联块。
不兼容 Firefox 2:
HTML 示例
Firefox 2 兼容性
HTML 示例
在您的 .button 实现中,您需要删除显示:内联部分。
In CSS, elements with display: inline cannot have width or height applied to them. You need display: inline-block for that. IE will incorrectly convert any inline element to inline-block if you give them a width or height. Fortunatley, since the release of Firefox 3 you can use inline-block with only minimal hacking.
no Firefox 2 compatibility:
Example HTML
Firefox 2 compatibilty
Example HTML
In your .button implementation you would need to remove the display: inline portion.