View Full Version : سوال: تعیین ارتفاع DIV به صورت استاتیک
  
rash44
یک شنبه 11 مرداد 1394, 15:36 عصر
سلام
در فایل پیوستی و کلاس:
        .menu-item:hover ul
        {
            height: 93px;
        }
اگر بخوام بجای مقدار ثابت 93 ، این مقدار با توجه به تعداد منوی های زیر مجوعه تغییر کنه باید به چهص ورتی عمل بشه ؟
زیر منو ها به صورت استاتیک از دیتابیس خونده میشه
mohammad425
یک شنبه 11 مرداد 1394, 15:39 عصر
اگه میخواین ارتفاع خودکار بیشتر بشه از min-height استفاده کنید.
rash44
یک شنبه 11 مرداد 1394, 16:06 عصر
اگه میخواین ارتفاع خودکار بیشتر بشه از min-height استفاده کنید.
از min-height که ساتفاده میشه در کد فوق ، انیمشن اسکرپیت از کارمی افته
mohammad425
یک شنبه 11 مرداد 1394, 16:14 عصر
خوب باید transition رو هم تغییر بدین
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            height: 0px;
            list-style-type: none;
            overflow: hidden;
            padding: 0px; /*Animation*/
            -webkit-transition: min-height 1s ease;
            -moz-transition: min-height 1s ease;
            -o-transition: height 1s ease;
            -ms-transition: min-height 1s ease;
            transition: min-height 1s ease;
        }
        .menu-item:hover ul
        {
            min-height: 93px;
        }
rash44
یک شنبه 11 مرداد 1394, 16:19 عصر
خوب باید transition رو هم تغییر بدین
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            height: 0px;
            list-style-type: none;
            overflow: hidden;
            padding: 0px; /*Animation*/
            -webkit-transition: min-height 1s ease;
            -moz-transition: min-height 1s ease;
            -o-transition: height 1s ease;
            -ms-transition: min-height 1s ease;
            transition: min-height 1s ease;
        }
        .menu-item:hover ul
        {
            min-height: 93px;
        }
ممنون
هیچ تغییر نکرد و مانند حالت قبل هست که انیمیشن از کار افتاده
mohammad425
یک شنبه 11 مرداد 1394, 16:22 عصر
کش مرورگرتونو پاک بکنید
من تست کردم درست کار میکنه
mohammad425
یک شنبه 11 مرداد 1394, 16:23 عصر
البته من یادم رفت این قسمت
  -o-transition: height 1s ease;
از min-height استفاده کنم, شما height رو به min-height تغییر بدین
rash44
یک شنبه 11 مرداد 1394, 16:31 عصر
در کد زیر منوی های 3 و 4 را بررسی کنید
منوی 3 دارای 2 زیر منو هست ولی ارتفاع ان هم 93 پیکسل می باشد و منوی 4 که دارای 4 زیر منو  هست فقط 3 آیتم آن نمایش داده میشه ( به دلیل ارتفاع 93 پیکسل)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Menu</title>
    
    <style type="text/css">
        /*autor: Mehdi Ahadi
        Email: mehdi.ahadi@webmehraz.ir
        */
        *
        {
            margin: 0px;
            padding: 0px;
        }
        
        body
        {
            background: #e5e5e7;
        }
        
        nav
        {
            font-family: Helvetica, Arial, "Lucida Grande" , sans-serif;
            line-height: 1.5;
            margin: 50px auto; /*for display only*/
            width: 200px;
            -webkit-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
            -moz-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
            box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
        }
        
        .menu-item
        {
            background: #fff;
            width: 200px;
        }
        /*Menu Header Styles*/
        .menu-item h4
        {
            border-bottom: 1px solid rgba(0,0,0,0.3);
            border-top: 1px solid rgba(255,255,255,0.2);
            color: #fff;
            font-size: 15px;
            font-weight: 500;
            padding: 7px 12px; /*Gradient*/
            background: #a90329; /* Old browsers */
            background: -moz-linear-gradient(top, #a90329 0%, #8f0222 44%, #6d0019 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a90329), color-stop(44%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* IE10+ */
            background: linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* W3C */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a90329', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
        }
        
        .menu-item h4 a
        {
            color: white;
            display: block;
            text-decoration: none;
            width: 200px;
        }
        /*Menu Header Styles*/
        .menu-item h4
        {
            border-bottom: 1px solid rgba(0,0,0,0.3);
            border-top: 1px solid rgba(255,255,255,0.2);
            color: #fff;
            font-size: 15px;
            font-weight: 500;
            padding: 7px 12px; /*Gradient*/
            background: #a90329; /* Old browsers */
            background: -moz-linear-gradient(top, #a90329 0%, #8f0222 44%, #6d0019 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a90329), color-stop(44%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* IE10+ */
            background: linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* W3C */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a90329', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
        }
        .menu-item h4:hover
        {
            background: #cc002c; /* Old browsers */
            background: -moz-linear-gradient(top,  #cc002c 0%, #6d0019 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cc002c), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* IE10+ */
            background: linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* W3C */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc002c', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
        }
        /*First Item Styles*/
        .alpha p
        {
            font-size: 13px;
            padding: 8px 12px;
            color: #aaa;
        }
        /*ul Styles*/
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            list-style-type: none;
            overflow: hidden;
            padding: 0px;
        }
        
        .menu-item ul a
        {
            margin-left: 20px;
            text-decoration: none;
            color: #aaa;
            display: block;
            width: 200px;
        }
        
        /*li Styles*/
        .menu-item li
        {
            border-bottom: 1px solid #eee;
        }
        
        .menu-item li:hover
        {
            background: #eee;
        }
        /*ul Styles*/
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            height: 0px; /*Collapses the menu*/
            list-style-type: none;
            overflow: hidden;
            padding: 0px;
        }
        /*ul Styles*/
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            height: 0px;
            list-style-type: none;
            overflow: hidden;
            padding: 0px; /*Animation*/
            -webkit-transition: min-height 1s ease;
            -moz-transition: min-height 1s ease;
            -o-transition: min-height 1s ease;
            -ms-transition: min-height 1s ease;
            transition: min-height 1s ease;
        }
        .menu-item:hover ul
        {
            min-height: 93px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div align="left">
        <nav>
    <div class="menu-item alpha">
      <h4><a href="#">Home</a></h4>
      <p>Lorem ipsum dolor sit...</p>
    </div>
       
    <div class="menu-item">
      <h4><a href="#">Portfolio</a></h4>
      <ul>
        <li><a href="#">Web</a></li>
        <li><a href="#">Print</a></li>
        <li><a href="#">Other</a></li>
      </ul>
    </div>
       
    <div class="menu-item">
      <h4><a href="#">منوی 3</a></h4>
      <ul>
        <li><a href="#">History</a></li>
        <li><a href="#">Meet The Owners</a></li>
      </ul>
    </div>
       
    <div class="menu-item">
      <h4><a href="#">منوی4</a></h4>
      <ul>
        <li><a href="#">Phone</a></li>
        <li><a href="#">Email</a></li>
        <li><a href="#">Location</a></li>
        <li><a href="#">Locatddddion</a></li>
      </ul>
    </div>
</nav>
    </div>
    </form>
</body>
</html>
mohammad425
یک شنبه 11 مرداد 1394, 19:22 عصر
یدونه height:100% اضافه کنید نشون میده ولی انیمیشن باز شدنش خراب میشه و هرکاری کردم درست نشد, چون زیاد با انمیشن کار نکردم باهاش آشنا نیستم
از دوستان اگه کسی میتونه انمیشنشو درست کنه
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Menu</title>
    
    <style type="text/css">
        /*autor: Mehdi Ahadi
        Email: mehdi.ahadi@webmehraz.ir
        */
        *
        {
            margin: 0px;
            padding: 0px;
        }
        
        body
        {
            background: #e5e5e7;
        }
        
        nav
        {
            font-family: Helvetica, Arial, "Lucida Grande" , sans-serif;
            line-height: 1.5;
            margin: 50px auto; /*for display only*/
            width: 200px;
            -webkit-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
            -moz-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
            box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
        }
        
        .menu-item
        {
            background: #fff;
            width: 200px;
        }
        /*Menu Header Styles*/
        .menu-item h4
        {
            border-bottom: 1px solid rgba(0,0,0,0.3);
            border-top: 1px solid rgba(255,255,255,0.2);
            color: #fff;
            font-size: 15px;
            font-weight: 500;
            padding: 7px 12px; /*Gradient*/
            background: #a90329; /* Old browsers */
            background: -moz-linear-gradient(top, #a90329 0%, #8f0222 44%, #6d0019 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a90329), color-stop(44%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* IE10+ */
            background: linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* W3C */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a90329', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
        }
        
        .menu-item h4 a
        {
            color: white;
            display: block;
            text-decoration: none;
            width: 200px;
        }
        /*Menu Header Styles*/
        .menu-item h4
        {
            border-bottom: 1px solid rgba(0,0,0,0.3);
            border-top: 1px solid rgba(255,255,255,0.2);
            color: #fff;
            font-size: 15px;
            font-weight: 500;
            padding: 7px 12px; /*Gradient*/
            background: #a90329; /* Old browsers */
            background: -moz-linear-gradient(top, #a90329 0%, #8f0222 44%, #6d0019 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a90329), color-stop(44%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* IE10+ */
            background: linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* W3C */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a90329', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
        }
        .menu-item h4:hover
        {
            background: #cc002c; /* Old browsers */
            background: -moz-linear-gradient(top,  #cc002c 0%, #6d0019 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cc002c), color-stop(100%,#6d0019)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* IE10+ */
            background: linear-gradient(top,  #cc002c 0%,#6d0019 100%); /* W3C */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc002c', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
        }
        /*First Item Styles*/
        .alpha p
        {
            font-size: 13px;
            padding: 8px 12px;
            color: #aaa;
        }
        /*ul Styles*/
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            list-style-type: none;
            overflow: hidden;
            padding: 0px;
        }
        
        .menu-item ul a
        {
            margin-left: 20px;
            text-decoration: none;
            color: #aaa;
            display: block;
            width: 200px;
        }
        
        /*li Styles*/
        .menu-item li
        {
            border-bottom: 1px solid #eee;
        }
        
        .menu-item li:hover
        {
            background: #eee;
        }
        /*ul Styles*/
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            height: 0px; /*Collapses the menu*/
            list-style-type: none;
            overflow: hidden;
            padding: 0px;
        }
        /*ul Styles*/
        .menu-item ul
        {
            background: #fff;
            font-size: 13px;
            line-height: 30px;
            height: 0px;
            list-style-type: none;
            overflow: hidden;
            padding: 0px; /*Animation*/
            -webkit-transition: min-height 1s ease;
            -moz-transition: min-height 1s ease;
            -o-transition: min-height 1s ease;
            -ms-transition: min-height 1s ease;
            transition: min-height 1s ease;
        }
        .menu-item:hover ul
        {
            min-height: 93px;
            height:100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div align="left">
        <nav>
    <div class="menu-item alpha">
      <h4><a href="#">Home</a></h4>
      <p>Lorem ipsum dolor sit...</p>
    </div>
       
    <div class="menu-item">
      <h4><a href="#">Portfolio</a></h4>
      <ul>
        <li><a href="#">Web</a></li>
        <li><a href="#">Print</a></li>
        <li><a href="#">Other</a></li>
      </ul>
    </div>
       
    <div class="menu-item">
      <h4><a href="#">About</a></h4>
      <ul>
        <li><a href="#">History</a></li>
        <li><a href="#">Meet The Owners</a></li>
        <li><a href="#">Awards</a></li>
      </ul>
    </div>
       
    <div class="menu-item">
      <h4><a href="#">Contact</a></h4>
      <ul>
        <li><a href="#">Phone</a></li>
        <li><a href="#">Email</a></li>
        <li><a href="#">Location</a></li>
       <li><a href="#">mohammad</a></li>
      </ul>
    </div>
</nav>
    </div>
    </form>
</body>
</html>
amirtc
دوشنبه 12 مرداد 1394, 00:02 صبح
برای انیمیشن یک ارتفاع معین باید باشه تا رخ داد صورت بگیره البته با جاوا میشه این منو رو درست کرد ! همچنین میشه برای li ها هم موقع اضافه شدن ارتفاع خاصی رو در نظر گرفت.
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.