html - 填充溢出文本字段中的容器

标签 html css

我正在尝试为文本字段分配填充,但右侧覆盖了主要内容。我该如何解决?

     <div class='contenedor_section'>
      <input type='text' placeholder='name' class='estilo_input_text'>
     </div>


    .contenedor_section{
      padding: 20px;
      background:red;
    }
    .estilo_input_text {
        display: block;
        width: 100%;
        height: 34px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        border: 1px solid #ccc;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
        box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
        -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
        transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    }

    ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
      font-style: italic;
      color: #999999 !important;
    }

https://jsfiddle.net/ys0yb15s/

最佳答案

否定您应用的填充。或者使用边框框。 calc 函数非常方便,并得到广泛支持,使用它吧!

.contenedor_section{
  padding: 20px;
  background:red;
}
.estilo_input_text {
    display: block;
    width: calc(100% - 24px);/* you have to negate the padding of 12px on each side */
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    color: #555;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
    -webkit-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}

::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  font-style: italic;
  color: #999999 !important;
}
  <div class='contenedor_section'>
    <input type='text' placeholder='name' class='estilo_input_text'>
  </div>

关于html - 填充溢出文本字段中的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43577270/

相关文章:

html - SVG 条纹图案作为元素背景图像

javascript - 如何通过 angularjs 服务正确重新连接到套接字?

javascript - 跟踪 pagesource 中发现的 javascript

javascript - 如何在移动网站中实现底部标签栏

jquery - 如何在响应式设计中重新排列 block 元素的顺序?

css - 响应式 Twitter 嵌入

javascript - 附加一个包含对象 id 的 div

html - 哪些 CSS 属性会影响 "height"属性值?

css - 如何从javafx中的一个样式表为具有相同类的节点设置不同的样式

jquery - Bootstrap 3 将页脚齐平到页面底部