Показано с 1 по 11 из 11

Тема: Помагите с формой

  1. #1

    Регистрация
    04.04.2005
    Адрес
    Kiev
    Сообщений
    6
    Подскажите плз как правильно сделать форму с помощью css.
    После 'Date:' все выглядит криво...
    Если кто знает как это правильно сделать, подскажите плз.



    <html>
    <head>
    <title>form</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="css/style.css" type="text/css" rel="stylesheet"></head><body>
    <form action="blabla.com" method="post">
    <div id="user-login-form">
    <div class="form-item">
    <label>Your Name: </label>
    <input maxlength="60" name="name" size="15" value="" class="form-text" type="text"> *
    </div>
    <div class="form-item">
    <label>Test here: </label>
    <input type="checkbox" name="faaa" value="bb"> *
    </div>
    <div class="form-item">
    <label>Your Surname: </label>
    <input maxlength="60" name="name" size="15" value="" class="form-text" type="text">hello
    </div>
    <div class="form-item">
    <label>E-mail address: </label>
    <select name="" class="form-text">
    <option value="aa">text 1 goes here</option>
    <option value="bb">text 2 goes here</option>
    </select>
    * </div>
    <div class="form-item">
    <label>Your text: </label>
    <input maxlength="60" name="name" size="15" value="" class="form-text" type="text">
    </div>
    <div class="form-item">
    <label>Your 2: </label>
    <input maxlength="60" name="name" size="15" value="" class="form-text" type="text">
    </div>
    <div class="form-item">
    <label>Date:</label>
    Text:
    <select name="" class="form-text2">
    <option value="aa">1982</option>
    <option value="bb">2007</option>
    </select>
    Year:
    <select name="" class="form-text2">
    <option value="aa">1982</option>
    <option value="bb">2007</option>
    </select>
    </div>
    <div class="form-item">
    <label>Your 4: </label>
    <input maxlength="60" name="name" size="15" value="" class="form-text" type="text">
    </div>
    <div class="form-item">
    <input name="op" value="Send" class="form-submit" type="submit">
    </div>
    </div>
    </form>
    </body></html>


    ===============


    body {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
    background: #ffffff;
    height:100%;
    padding: 0px;
    margin: 0px;
    }
    .form-item{
    padding-top: 5px;
    padding-left: 100px;
    }
    label{
    width: 200px;
    color: #000000;
    font-weight: bold;
    float: left;
    text-align:right;
    padding-top:3px;
    }
    #user-login-form input {
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: solid;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: #5C88E1;
    border-right-color: #5C88E1;
    border-bottom-color: #5C88E1;
    border-left-color: #5C88E1;
    background-color: #ffffff;
    }
    #user-login-form .form-submit
    {
    margin-top: 5px;
    margin-left:100px;
    font-weight: bold;
    color: #000000;
    padding-bottom: 1px;
    border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: solid;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: #828282;
    border-right-color: #828282;
    border-bottom-color: #828282;
    border-left-color: #828282;
    }
    #user-login-form .form-text {
    width:300px;
    }
    #user-login-form .form-text2 {
    width:100px;
    }
    #nn1 {
    width: 200px;
    color: #000000;
    font-weight: bold;
    float: left;
    text-align:right;
    padding-top:3px;
    }
    #nn2 {
    }
    span{
    color:#FF0000;
    padding-bottom:2px;
    }

  2. #2

    Регистрация
    15.11.2006
    Адрес
    Тольятти
    Сообщений
    2,698
    [Только зарегистрированные пользователи могут видеть ссылки. ] правильно. Код не смотрел...

  3. #3

    Регистрация
    23.03.2004
    Адрес
    Беларусь/Минск
    Сообщений
    926
    Originally posted by lsa@Jul 25 2007, 14:18
    [b]border-top-width: 1px;
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: solid;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: #5C88E1;
    border-right-color: #5C88E1;
    border-bottom-color: #5C88E1;
    border-left-color: #5C88E1;
    }
    как же тяжело читать такой код

  4. #4

    Регистрация
    15.11.2006
    Адрес
    Тольятти
    Сообщений
    2,698
    Вот я и не читал)

  5. #5

    Регистрация
    04.04.2005
    Адрес
    Kiev
    Сообщений
    6
    так подскажите плз как правильно
    смотрел по ссылке пример
    но когда я добавляю по два select в одну строку а между ними текст (как в моем примере) то все выглядит криво....

    помогите плз как правильно это сделать.

  6. #6

    Регистрация
    23.03.2004
    Адрес
    Беларусь/Минск
    Сообщений
    926
    Originally posted by lsa@Jul 26 2007, 08:29
    [b]так подскажите плз как правильно
    я имел в виду, что надо сокращать код, тот пример можно так сократить

    Код:
    border-top: 1px solid #5C88E1;
    border-right: 1px solid #5C88E1;
    border-bottom: 1px solid #5C88E1;
    border-left: 1px solid #5C88E1;
    а ссылку вам дали, где подробно описывается, как делать формы без таблиц...

  7. #7

    Регистрация
    04.04.2005
    Адрес
    Kiev
    Сообщений
    6
    по поводу как сократить мой корявый код - я понял, сенкс!

    а по поводу как сделать вместо одного select - два и чтобы между ними текст был(как в моем примере) я не знаю - это основной вопрос который меня интересует

  8. #8

    Регистрация
    15.11.2006
    Адрес
    Тольятти
    Сообщений
    2,698
    Вы вообще о предназначении элемента <lable> слышали чего-нибудь? Или Вы думаете, что он только для выравнивания и нужен, да? Почему для полей не указаны идентификаторы, а для лэйблов – атрибут "for"? Вот это: "Text:", "Year:" – это ЧТО?

  9. #9

    Регистрация
    04.04.2005
    Адрес
    Kiev
    Сообщений
    6
    нет. Но думаю услышу
    в нете нарыл приблизительно то что мне надо буду разбираться...

    <style type="text/css">
    /* All form elements are within the definition list for this example */
    dl {
    font:normal 12px/15px Arial;
    position: relative;
    width: 350px;
    }
    dt {
    clear: both;
    float:left;
    width: 100px;
    padding: 4px 0 2px 0;
    text-align: right;
    }
    dd {
    float: left;
    width: 200px;
    margin: 0 0 8px 0;
    padding-left: 6px;
    }


    /* The hint to Hide and Show */
    .hint {
    display: none;
    position: absolute;
    right: -250px;
    width: 200px;
    margin-top: -4px;
    border: 1px solid #c93;
    padding: 10px 12px;
    /* to fix IE6, I can&#39;t just declare a background-color,
    I must do a bg image, too! So I&#39;m duplicating the pointer.gif
    image, and positioning it so that it doesn&#39;t show up
    within the box */
    background: #ffc url(pointer.gif) no-repeat -10px 5px;
    }

    /* The pointer image is hadded by using another span */
    .hint .hint-pointer {
    position: absolute;
    left: -10px;
    top: 5px;
    width: 10px;
    height: 19px;
    background: url(pointer.gif) left top no-repeat;
    }
    </style>
    <script type="text/javascript">
    function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != &#39;function&#39 {
    window.onload = func;
    } else {
    window.onload = function() {
    oldonload();
    func();
    }
    }
    }

    function prepareInputsForHints() {
    var inputs = document.getElementsByTagName("input");
    for (var i=0; i<inputs.length; i++){
    // test to see if the hint span exists first
    if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
    // the span exists! on focus, show the hint
    inputs[i].onfocus = function () {
    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    // when the cursor moves away from the field, hide the hint
    inputs[i].onblur = function () {
    this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
    }
    }
    // repeat the same tests as above for selects
    var selects = document.getElementsByTagName("select");
    for (var k=0; k<selects.length; k++){
    if (selects[k].parentNode.getElementsByTagName("span")[0]) {
    selects[k].onfocus = function () {
    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
    }
    selects[k].onblur = function () {
    this.parentNode.getElementsByTagName("span")[0].style.display = "none";
    }
    }
    }
    }
    addLoadEvent(prepareInputsForHints);
    </script>
    </head>
    <body>
    <p style="font:normal 12px/15px Arial;">Tab or click through the fields to reveal the hints.</p>

    <dl>
    <dt>
    <label for="firstname">First Name:</label>
    </dt>
    <dd>
    <input
    name="firstname"
    id="firstname"
    type="text" />
    This is the name your mama called you when you were little.<span class="hint-pointer"></span>
    </dd>
    <dt>
    <label for="lastname">Last Name:</label>
    </dt>
    <dd>
    <input
    name="lastname"
    id="lastname"
    type="text" />
    This is the name your sergeant called you when you went through bootcamp.<span class="hint-pointer"></span>
    </dd>
    <dt>
    <label for="email">Email:</label>
    </dt>
    <dd>
    <input
    name="email"
    id="email"
    type="text" />
    The thing with the @ symbol and the dot com at the end.<span class="hint-pointer"></span>
    </dd>
    <dt><label for="year">Birth Year:</label></dt>
    <dd>
    <select id="year" name="year">
    <option value="">YYYY</option>
    <option value="1066">1066</option>
    <option value="1492">1492</option>
    <option value="1776">1776</option>
    <option value="1812">1812</option>
    <option value="1917">1917</option>
    <option value="1942">1942</option>
    <option value="1999">1999</option>
    </select>
    Hello
    <select id="year" name="year">
    <option value="">YYYY</option>
    <option value="1066">1066</option>
    <option value="1492">1492</option>
    <option value="1776">1776</option>
    <option value="1812">1812</option>
    <option value="1917">1917</option>
    <option value="1942">1942</option>
    <option value="1999">1999</option>
    </select>
    Pick a famous year to be born in.<span class="hint-pointer"></span>
    </dd>
    <dt>
    <label for="username">Username:</label>
    </dt>
    <dd>
    <input
    name="username"
    id="username"
    type="text" />
    Between 4-12 characters.<span class="hint-pointer"></span>
    </dd>
    <dt>
    <label for="password">Password:</label>
    </dt>
    <dd>
    <input
    name="password"
    id="password"
    type="password" />
    Between 5-13 characters, but not 7. Never 7.<span class="hint-pointer"></span>
    </dd>
    <dt class="button"></dt>
    <dd class="button">
    <input
    type="submit"
    class="button"
    value="Submit" />
    </dd>
    </dl>

  10. #10

    Регистрация
    23.03.2004
    Адрес
    Беларусь/Минск
    Сообщений
    926
    ой, лучше не стоит использовать списки определени в формах, это семантически неверно

  11. #11

    Регистрация
    15.11.2006
    Адрес
    Тольятти
    Сообщений
    2,698
    и куча лишних дивов там совсем не обязательна...

Похожие темы

  1. Помогите с формой обратной связи
    от alexXXL в разделе Веб-программирование
    Ответов: 2
    Последнее сообщение: 18.08.2008, 21:16
  2. Помагите
    от Rc helicopter в разделе Вёрстка сайта
    Ответов: 11
    Последнее сообщение: 13.01.2008, 23:01
  3. Помагите найти суды и профектуры
    от zebu в разделе Флейм
    Ответов: 1
    Последнее сообщение: 23.11.2007, 14:39
  4. работа с формой
    от schrec в разделе Веб-программирование
    Ответов: 1
    Последнее сообщение: 22.12.2006, 23:19
  5. Помогите с формой!
    от Iren в разделе Веб-программирование
    Ответов: 2
    Последнее сообщение: 22.09.2006, 11:56

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •