首页 > 软件开发 > JQUERY >

jQuery文本框宽度随着输入内容而自动变化

来源:互联网 2023-03-16 23:54:42 333

jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

工具/原料

  • adobe dreamweaver

方法/步骤

  • 1

    新建html文档。9nK办公区 - 实用经验教程分享!

    jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

  • 2

    书写hmtl代码。div id="main_demo">form onSubmit="$('#demo-input').blur().focus();return false;" class="pure-form" style="border-top: 1px solid #eee;border-bottom:1px solid #eee;background:#fafafa;margin:30px 0;padding:20px 10px;text-align:center"> div id="demo-input-container" style="margin:auto;width:100%;max-width:600px"> input id="demo-input" autofocus type="text" name="q" placeholder="输入文本…"> /div>/form>9nK办公区 - 实用经验教程分享!

    jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

  • 3初始化css代码。style>body { margin: 0; padding: 0; border: 0; min-width: 320px; color: #777; }html, button, input, select, textarea, .pure-g [class *= "pure-u"] { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1.02em; }p, td { line-height: 1.5; }ul { padding: 0 0 0 20px; }th { background: #eee; white-space: nowrap; }th, td { padding: 10px; text-align: left; vertical-align: top; font-size: .9em; font-weight: normal; border-right: 1px solid #fff; }td:first-child { white-space: nowrap; color: #008000; width: 1%; font-style: italic; }h1, h2, h3 { color: #4b4b4b; font-family: "Source Sans Pro", sans-serif; font-weight: 300; margin: 0 0 1.2em; }h1 { font-size: 4.5em; color: #1f8dd6; margin: 0 0 .4em; }h2 { font-size: 2em; color: #636363; }h3 { font-size: 1.8em; color: #4b4b4b; margin: 1.8em 0 .8em }h4 { font: bold 1em sans-serif; color: #636363; margin: 4em 0 1em; }a { color: #4e99c7; text-decoration: none; }a:hover { text-decoration: underline; }p, pre { margin: 0 0 1.2em; }::selection { color: #fff; background: #328efd; }::-moz-selection {color: #fff;background: #328efd;}/style>

    jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

  • 4

    书写css代码。style>@media (max-width:480px) {h1 { font-size: 3em; }h2 { font-size: 1.8em; }h3 { font-size: 1.5em; }td:first-child { white-space: normal; }}.inline-code { padding: 1px 5px; background: #eee; border-radius: 2px; }pre { padding: 15px 10px; font-size: .9em; color: #555; background: #edf3f8; }pre i { color: #aaa; } /* comments */pre b { font-weight: normal; color: #cf4b25; } /* strings */pre em { color: #0c59e9; } /* numeric *//* Pure CSS */.pure-button { margin: 5px 0; text-decoration: none !important; }.button-lg { margin: 5px 0; padding: .65em 1.6em; font-size: 105%; }input[type="text"] { display: inline !important; margin: 0; }/style>9nK办公区 - 实用经验教程分享!

    jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

  • 5

    代码整体结构。9nK办公区 - 实用经验教程分享!

    jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

  • 5此文章未经许可获取自百度经验
  • 6

    查看效果。9nK办公区 - 实用经验教程分享!

    jQuery文本框宽度随着输入内容而自动变化9nK办公区 - 实用经验教程分享!

  • 以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!9nK办公区 - 实用经验教程分享!


    标签: JQUERY

    办公区 Copyright © 2016-2023 www.bgqu.net. Some Rights Reserved. 备案号:湘ICP备2020019561号统计代码