html - 设计一个按钮

标签 html css cross-browser

http://jsfiddle.net/eS7bC/5/

button[type=submit] {
    width: 101px; height: 16px;
    background-color: #f68830;
    -webkit-border-radius: 9px; -moz-border-radius: 9px; border-radius: 9px;
    border: none; 
    cursor:pointer;
}

button[type=submit]:hover::after {
    content:'';
    background-color: #f68830;
    width:6px; height:6px;
    -webkit-border-radius: 50%; -moz-border-radius: 50%; border-radius: 50%;
    vertical-align:middle;
    float: right;
    background-color: #d9e4ea;
    margin: 0; padding: 0;
}

我有一个按钮,可以在悬停 时改变它的样式。它在 Chrome 上工作并且看起来很好,但在其他浏览器中存在问题。在 Firefox 上,hover 上出现的点有点不合适,当您将鼠标悬停或单击时,按钮会移动。 IE 与 Firefox 有类似的问题。问题是如何设置它的样式以使其在所有浏览器中的行为和外观都相同?

最佳答案

这是因为 float:right 属性。试试这个

button[type=submit] {
    width: 101px; height: 16px;
    background-color: #f68830;
    webkit-border-radius: 9px; -moz-border-radius: 9px; border-radius: 9px;
    border: none; 
    cursor:pointer;
    margin: 0; padding: 0;
    position: relative;
}

button[type=submit]:hover::after {
    content:'';
    background-color: #f68830;
    width:6px; height:6px;
    webkit-border-radius: 50%; -moz-border-radius: 50%; border-radius: 50%;
    position: absolute;
    right: 6px;
    top: 5px;
    background-color: #d9e4ea;
    margin: 0; padding: 0;
}

关于html - 设计一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23156676/

相关文章:

jquery - 单击其他菜单项时如何改回并隐藏我的菜单?

html - 在没有flexbox的情况下并排对齐三个div

javascript - 确定从 jQuery/JavaScript 中单击了哪个提交按钮

html - 为什么我不能对齐两个按钮

javascript - Bootstrap 响应在包含 Viewport meta 后不起作用

javascript - 将 JSON 数据设置为变量并递增 + 打印

css - 输入字段内的验证 Rails bootstrap simple_form

php - 忽略标题标签中的上标

html - box-sizing 功能不正常

html - 如何创建一个网页来捕获用户在手机和计算机中的摄像头?