1

私はウェブサイトを作成していて、いくつかのボタンを作成し、それらに-webkit-box-flexプロパティを追加しました。それはうまくいきました。ただし、ボタンの1つにドロップダウンメニューを追加すると、-webkit-box-flexプロパティがボタンに適用されなくなり、機能しなくなります。誰かが何が起こっているのか教えてもらえますか?

これがjsfiddleです:

http://jsfiddle.net/hGT6E/

*{
margin: 0px;
padding: 0px;
 }

h1{
font: bold 20px PrimaSans BT;
 }

 h2{
font: italic 14px PrimaSans BT;
  }

header, section, footer, aside, nav, article, hgroup, ul, li{
 display: block;
 }

 #wrapper{
max-width: 1000px;
margin: 20px 0px;
display: -webkit-box;
display: -moz-box;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;

-webkit-box-flex: 1;
-moz-box-flex: 1;
margin-left: auto ;
margin-right: auto ;
}

#searchbox{
float: right;
margin-bottom: 10px;
}

body{
width: 100%;
margin: 0;
display:-moz-box;
-moz-box-pack: center;
display:-webkit-box;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0,    `enter code here`#ffffff), color-stop(1, #bababa));
background-image: -moz-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#ffffff), color-stop(1, #bababa));
background-repeat: no-repeat;
background-attachment: fixed;
  }

 #navigation{
display: block;
padding: 10px;
margin: 5px;
margin-bottom: 0px;
-webkit-border-radius: 15px;
width: 800px;
height: 60px;
display: -webkit-box;
-webkit-box-orient: horizontal;
display: -moz-box;
-moz-box-orient: horizontal;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#ffffff), color-stop(1, #bababa));
background-image: -moz-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#ffffff), color-stop(1, #bababa));

 }

 #navigation li:hover ul{
display: block;
 }

 #navigation ul{
margin: 0px;
padding: 0px;
 }

 #navigation li{
position: relative;
float: left;
list-style-type: none;
 }

 #navigation ul:after{
display: block;
clear: both;
visibility: hidden;
 }

  #navigation li a{
text-decoration: none;
display: block;
color: black;
border-right: 1px solid grey;
padding: 10px 25px;

 }

  #navigation ul ul{
position: absolute;
border: 20px;
left: 0px;
width: 125px;
display: none;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#ffffff), color-stop(1, #bababa));
  }

  #navigation ul ul li{
border: 1px solid grey;
width: 99%;
-webkit-transition: background 2s
  }

   #navigation ul ul li:hover{
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#fffc01), color-stop(1, #ffde00));
  }

 #navigation ul ul li a{
border-right: none;
  }

  .navigation_button{
font: bold 18px PrimaSans BT;
-webkit-box-flex: 1;
width: 100px;
padding: 10px;
margin: 10px;
text-align: center;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#ffffff), color-stop(1, #bababa));
background-image: -moz-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#ffffff), color-stop(1, #bababa));
-webkit-border-radius: 10px;
-webkit-transition: -webkit-transform 2s, opacity 2s, background 2s, scale 2s,
  }

   .navigation_button:hover{
-webkit-transform: scale(1.05);
opacity: 1;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#fffc01), color-stop(1, #ffde00));
background-image: -moz-gradient(linear, left top, left bottom, color-stop(0, `enter code here`#fffc01), color-stop(1, #ffde00));
 }

 #main_section{
border: 1px solid grey;
width: 750px;
margin-left: 40px;
margin-right: 30px;
border-top: 0px;
height: 800px;
margin-bottom: 10px;
-webkit-border-bottom-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
background-color: #f1f1f1;
-webkit-box-flex: 1;
 }

 .article_1{
border: 1px solid gray;
background: white;
-webkit-box-flex: 1;
margin-left: 10px;
margin-right: 10px;
margin-top: 10px;
padding: 10px;
  }

  .article_1_footer{
text-align: right;
  }

  #footer{
text-align: center;
font: italic 12px Times New Roman
  }

ありがとう!

4

2 に答える 2

0

box-flexプロパティ (現在の名前: ) は、フレックス アイテムflexであるアイテムに対してのみ機能します。フレックス アイテムであるためには、その親要素がフレックス コンテナー(表示値が box/flexbox/flex である) である必要があります。要素の親はで、その表示タイプはブロックです。.navigation_buttonul#nav_menu

http://jsfiddle.net/hGT6E/1/

#nav_menu {
    display: -webkit-box;
    width: 100%;
}

これらのプロパティが利用可能であることに依存しないように注意する必要があります。これらは 2009 Flexbox 仕様のものであり、そう遠くない将来に廃止される可能性があります。古いモバイル ブラウザーをサポートする必要がある場合は、各プロパティに最新バージョンも提供するようにしてください。

于 2013-03-14T18:55:04.447 に答える
-1

シマノンが先に説明したように、

#parent {
    /* the parent has to be setup */
    display: -webkit-box;
    display: -moz-box;
    display: -o-box;
    display: box;
}

#child {
    /* for the child to behave correctly */
    -webkit-flex-box: 1;
    -moz-flex-box: 1;
    -o-flex-box: 1;
    flex-box: 1;
}

サポートされていないブラウザで表示していませんか?

一部のベンダー固有のプレフィックスが欠落している可能性があります (ブラウザーのアクセシビリティ スコープに関連して)。

これは、フレックスを使用する新しい学校の例です ( bennettfeely.com/flexplorerから生成)。

.flex-container {
    display: -webkit-flex;
    display: -moz-flex;
    display: -ms-flex;
    display: flex;
    -webkit-flex-flow: row wrap;
    -moz-flex-flow: row wrap;
    -ms-flex-direction: row;
    -ms-flex-wrap: wrap;
    -ms-flex-flow: row wrap;    
    flex-flow: row wrap;
}

.flex-item {
    -webkit-flex:1 auto;
    -moz-flex:1 auto;
    -ms-flex:1 auto;
    flex:1 auto;
}

Caniuseで flex ブラウザーのサポートを確認できます。

ユーザーCimmanonによって提起されたポイント、接頭辞付きのセレクターはあなたの質問に関係がないかもしれませんが、どういうわけか、.css宣言を読んだ後、「基本的な」CSS3宣言を設定していないことに気付きました (dispaly:box; flex-box:1; )。だから私は一瞬これがあなたの状況を説明するだろうと思ったが、そうではない.

于 2013-03-14T19:09:55.180 に答える