简体   繁体   English

CSS内联块在Firefox中不起作用

[英]css inline-block doesn't work in firefox

I have an one column bootstrap table and each cell contains two divs with text and buttons. 我有一个一列的引导程序表,每个单元格包含带有文本和按钮的两个div。

in Chrome, cell content is rendered as expected in one row 在Chrome中,单元格内容按预期呈现在一行中

在此处输入图片说明

but in firefox the cell content is rendered "in two rows" 但在Firefox中,单元格内容“分成两行”呈现

在此处输入图片说明

jsfiddle jsfiddle

html html

<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

javascript javascript

var data = [{"id":"973","email":"usr3@usr3.com"},{"id":"17f","email":"prom3@prom3.com"},{"id":"29e","email":"prom8@prom8.com"}];

class TableRowButtons extends React.Component {

    constructor(props) {
        super(props);

        this._handleDeleteClick = this._handleDeleteClick.bind(this);
        this._handleResetClick = this._handleResetClick.bind(this);
        this._handleEditClick = this._handleEditClick.bind(this);
    }

    _handleDeleteClick(e){
        console.log(e);
    }

    _handleResetClick(e){
        console.log(e);
    }

    _handleEditClick(e){
        console.log(e);
    }

    render() {

        return (
            <div className="row-container">
                <div className="row-text-container">
                    {this.props.cellContent}
                </div>
                <div className="row-buttons-container">
                    <button className="btn btn-danger btn-xs" onClick={this._handleDeleteClick}>Delete</button>
                    <button className="btn btn-warning btn-xs" onClick={this._handleResetClick}>Reset Password</button>
                    <button className="btn btn-info btn-xs" onClick={this._handleEditClick.bind}>Edit</button>
                </div>
            </div>
        );
    }
}

class TestTable extends React.Component{

  constructor(props) {
        super(props);

        this._handleEditClick = this._handleEditClick.bind(this);
        this._handleResetClick = this._handleResetClick.bind(this);
        this._handleDeleteClick = this._handleDeleteClick.bind(this);
        this._handleRowClick = this._handleRowClick.bind(this);
    }

    _handleRowClick(row){
        console.log(row);
    }

  _handleDeleteClick(rowContent){
        console.log(rowContent);
    }

    _handleResetClick(rowContent){
        console.log(rowContent);
    }

    _handleEditClick(rowContent){
        console.log(rowContent);
    }

  render(){

    var that = this;

    function onAfterTableComplete(){

        }

        const options = {
            onRowClick: this._handleRowClick,
            afterTableComplete: onAfterTableComplete
        };

    function rowFormatter(cell, row){
            return <TableRowButtons
                    cellContent={cell}
                    rowContent={row}
                    onDeleteClick={that._handleDeleteClick}
                    onResetClick={that._handleResetClick}
                    onEditClick={that._handleEditClick}
                    />;
        }

     return (
       <BootstrapTable
                    data={data}
                    striped={true}
                    hover={true}
                    condensed={true}
                    pagination={true}
                    search={true}
                    options={options}>
                    <TableHeaderColumn
                        isKey={true}
                        dataField="email"
                        width="200"
                        dataSort={true}
                        dataFormat={rowFormatter}>Email</TableHeaderColumn>
                </BootstrapTable>
     );
  }

}

ReactDOM.render(
  <TestTable />,
  document.getElementById('container')
);

css 的CSS

.btn-danger {
    margin-right: 0;
  }

  .btn-warning, .btn-info{
    margin-right: 5px;
  }

  td .btn{
    float: right;
  }

  .row-container{
  display: inline-block;
  width: 100%;
  }

  .row-container div{
    display: inline-block;
  }

  .row-buttons-container{
    float: right;
    width: 200px;
  }

The problem I see is the white-space: nowrap; 我看到的问题是white-space: nowrap;
change it, maybe it will help. 更改它,也许会有所帮助。

I'm gonna say Firefox is correct on this one. 我要说Firefox在这一点上是正确的。

Let's have a look what you get when you remove the float . 让我们看一下删除float会得到什么。 You have something like this: 你有这样的事情:

email@example.com email@example.com
[Edit] [Reset Password] [Delete] [编辑] [重置密码] [删除]

This is because they are <div> elements and as such are blocks. 这是因为它们是<div>元素,因此是块。

Then you apply the float:right to the button set. 然后将float:right应用于按钮集。 My question is: why do you expect the buttons to move up? 我的问题是:您为什么期望按钮向上移动? They should (and in Firefox, do) only move right. 它们应该(并且在Firefox中确实)仅向右移动。

To get the effect you want, consider having the buttons appear before the email in the HTML source. 为了获得所需的效果,请考虑使按钮出现在HTML源中的电子邮件之前。 This will make them float appropriately in all browsers. 这将使它们在所有浏览器中正确浮动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM