如何防止这个div的垂直滚动?

时间:2015-06-19 12:59:19

标签: html css css3 scroll xhtml

我不是很喜欢CSS而且我有以下问题。

我有以下情况:进入页面我有一个非常大的表(由于没有在页面中输入而被水平截断)。

因此,要解决此问题,我将此表放入可滚动的div中,如下所示:

<div style="overflow-x: scroll;">
    // Into this div there is my original table
</div>

所以我使用了 overflow-x:scroll; 属性,因为我希望div的内容只能水平滚动(不是垂直)。但问题是我得到了这个输出:

enter image description here

正如您所见,div内容结果也可以垂直滚动,我不想要它。我不能发布一个小提琴,因为内部表是由标签库呈现的。

如何解决此问题并仅获取水平卷轴?我错过了什么?

TNX

5 个答案:

答案 0 :(得分:2)

尝试

<div style="overflow-x: scroll; overflow-y:hidden;">
    // Into this div there is my original table
</div>

答案 1 :(得分:2)

overflow-y: visible;默认情况下应该存在,可能还有其他原因导致滚动条。查看Chrome调试程序中各种父overflow-y的{​​{1}}值。

答案 2 :(得分:2)

使溢出-y:隐藏。

OleDbConnection conexao = new OleDbConnection();
try
{

    OleDbCommand comando = new OleDbCommand();
    comando.Connection = conexao;
    string query2 = "update Utilizador set Nome='" + nomeTextBox.Text + "' , DiaNascimento='" + diaNascimentoComboBox.Text + "'  ,MesNascimento='" + mesNascimentoComboBox.Text + "'  ,AnoNascimento='" + anoNascimentoComboBox.Text + "' , Altura='" + alturaTextBox.Text + "' , Sexo='" + sexoComboBox.Text + "' , Peso='" + pesoTextBox.Text + "' , CodGenetica='" + codGeneticaTextBox1.Text + "', Login='" + loginTextBox.Text + "'  , Password='" + passwordTextBox.Text + "' where CodUtilizador= " + codutilizaor.Text + "";

    string id = codutilizaor.Text;
    string command = "update Utilizador set Nome= '" + nomeTextBox.Text + "' , Login= " + loginTextBox.Text + " where CodUtilizador= '" + id + "'  ";
    conexao.Open();
    conexao.Close();
    this.Close();
}
catch (Exception ex)
{
    MessageBox.Show("Ya" + ex);
}

答案 3 :(得分:2)

首先给你的div <div style="overflow: auto">然后看看。如果仍显示y轴上的滚动,请键入<div style="overflow-x: auto; overflow-y: hidden">

答案 4 :(得分:0)

.div {
  overflow-x: scroll;
  overflow-y: hidden;
}
<div class="div">
</div>