2

パイプ内のテキストを中央に配置せずに yahoo パイプをページの中央に配置するために、このサイトですべてを試しましたが、何も機能しません。私は本当にこれに2番目の目を必要としています! ここに私が持っているコードがあります:

CSS:

#pipe_container{
    width: 850px;
    height: 350px;
    position: relative;
    margin-left: auto;
    margin-right: auto;
    background-color: #fff;
    text-align: center;
}

#event_pipe {  
    position: relative;
    text-align:left;
    width:100%px;  
    height:350px;  
    background-color:#888;
    padding:0px;
    margin: 0px 20px 20px 20px;
}

HTML:

 <div id="pipe_container">
   <div id="event_pipe">     
       <script src="http://l.yimg.com/a/i/us/pps/listbadge_1.6.js">
        { 
          "pipe_id":"2a44070dcf6974aea04ad155a76caef4",
          "_btype":"list",
          "width":"80%",
          "height":"350px"
        }
      </script>
   </div>
</div>

「event_pipe」コードでセンタリング属性を使用することはできません。これは、テキストを含むすべてをセンタリングするためです。テキストを左側に残してほしい。

4

4 に答える 4

1

CSSを使用して動作させることができませんでした。引数としてパイプに渡す必要がありました。

 <div id="pipe_container">
   <div id="event_pipe">     
       <script src="http://l.yimg.com/a/i/us/pps/listbadge_1.6.js">
        {
          "pipe_id":"2a44070dcf6974aea04ad155a76caef4",
          "_btype":"list",
          "width":"80%",
          "height":"350px",
          "margin":"auto"
        }
      </script>
   </div>
</div>

JSON の最後の 2 行に注目してください。

"height":"350px",
"margin":"auto"

それがトリックをしたものです。

動作中の jsFiddle へのリンクを次に示します。

于 2012-05-16T13:42:50.660 に答える
0

あなたのスタイルを追加してください:

#event_pipe div:first-child {
          margin: 0px auto;
}
于 2012-05-16T13:36:52.940 に答える
0

これをローカル テスト用の head セクションに入れて、quirks モードにならないようにします。

<meta http-equiv="X-UA-Compatible" content="IE=edge">

このcssを試してください

#pipe_container{
  width: 850px;
  height: 350px;
  position: relative;
  margin:0 auto;
  background-color: #fff;
  text-align: center;
 }
#event_pipe > div{
  margin:0 auto;
 }
#event_pipe {  
position: relative;
text-align:left; 
height:350px;  
background-color:#888;
padding:0px;
margin: 0px 20px 20px 20px;
}
于 2012-05-16T13:38:14.867 に答える
0

#event_pipe ルールを次のように変更してみてください。

#event_pipe > div {  
    position: relative;
    text-align:left;
    width:100%px;  
    height:350px;  
    background-color:#888;
    padding:0px;
    margin: 0px auto;
}​
于 2012-05-16T13:34:43.980 に答える