2017-03-02 6 views
0

私は同様の質問が尋ねられていることを知っていますが、私はそれらの間で私の問題の答えを見つけることができませんでした。 左から250pxでメインに移動しようとしていますが、ラッパーを作成してスタイルをとろうとしたときに何もしませんでした。divタグのID(ID)が認識されません。

/* site.css */ 
 

 
body{ 
 
    font-family:sans-serif; 
 
    font-size: 14px; 
 
    margin:0; 
 
} 
 
label{ 
 
    font-weight:bold; 
 
    display:block; 
 
} 
 
input[type=text], input[type=password], textarea{ 
 
    width:150px; 
 
} 
 

 
#main{ 
 
    background-color: #eee; 
 
    padding:4px; 
 
    margin:0; 
 
} 
 
#footer{ 
 
    background-color:#222; 
 
    color:#eee; 
 
    padding:8px 4px; 
 
    position:fixed; 
 
    width:100%; 
 
    bottom:0; 
 
} 
 
.Headshot{ 
 
    max-width: 50px; 
 
    border: 1px solid #222; 
 
    padding: 3px; 
 
    
 
} 
 

 
.menu{ 
 
    font-size:11px; 
 
} 
 

 
.menu li{ 
 
    list-style-type: none; 
 
} 
 

 
.menu li.active { 
 
    font-weight:bold; 
 
} 
 
#sidebar { 
 
    background:#2a2c36; 
 
    color:#eee; 
 
    position:fixed; 
 
    height:100%; 
 
    width:250px; 
 
    overflow:hidden; 
 
    left:0; 
 
    margin:0; 
 
} 
 

 
#wrapper{ 
 
    left:0 0 0 250px; 
 
} 
 
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <title>The World</title> 
 
    <meta charset="utf-8" /> 
 
    <link rel="stylesheet" href="css/site.css" /> 
 

 
</head> 
 
<body> 
 
    <div id="sidebar"> 
 
     <img src="img/user1.jpg" alt="Headshot" class="Headshot"/> 
 
     <span>Sam Hastings </span> 
 
     <ul class="menu"> 
 
      <li class="active"><a href="#" >Home</a></li> 
 
      <li><a href="#">About</a></li> 
 
      <li><a href="#">Contact</a></li> 
 
     </ul> 
 
    </div> 
 
    <div id="wrapper"> 
 
     <div id="main"> 
 
      <h3>The World</h3> 
 
      <p>Ofineo website</p> 
 
      <form> 
 
       <div> 
 
        <label>Date</label> 
 
        <input /> 
 
       </div> 
 
       <div> 
 
        <label>Location</label> 
 
        <input /> 
 
       </div> 
 
       <div> <input type="submit" value="add" /></div> 
 
      </form> 
 
     </div> 
 
     <div id="footer"> 
 
      &copy; 2015 the world Ltd. 
 
     </div> 
 
    </div> 
 

 
</body> 
 
</html>

+1

使用 'マージン-left'。 – Toxide82

+1

は'のみ1つの引数を受け入れleft'の – ne1410s

+1

あなたもdivで 'position:'を使用していません – Toxide82

答えて

0

CSSのpropiety は(固定、または絶対)position:relativeで宣言されなければなりません。
そして、ただ1つの属性を設定してください。 left:250px、ないleft: 0 0 0 250px

#wrapper{ 
    left:250px; 
    position:relative; 
} 
+0

また、 'left'を' margin'に置き換えるとおそらく動作します。 – domsson

0

あなたはmarginを使用し、その後の位置を使用したくない場合。

ここ

#wrapper{ 
    margin:0 0 0 250px; 
} 

#wrapper{ 
    left:0 0 0 250px; 
} 

コード

/* site.css */ 
 

 
body { 
 
    font-family: sans-serif; 
 
    font-size: 14px; 
 
    margin: 0; 
 
} 
 

 
label { 
 
    font-weight: bold; 
 
    display: block; 
 
} 
 

 
input[type=text], 
 
input[type=password], 
 
textarea { 
 
    width: 150px; 
 
} 
 

 
#main { 
 
    background-color: #eee; 
 
    padding: 4px; 
 
    margin: 0; 
 
} 
 

 
#footer { 
 
    background-color: #222; 
 
    color: #eee; 
 
    padding: 8px 4px; 
 
    position: fixed; 
 
    width: 100%; 
 
    bottom: 0; 
 
} 
 

 
.Headshot { 
 
    max-width: 50px; 
 
    border: 1px solid #222; 
 
    padding: 3px; 
 
} 
 

 
.menu { 
 
    font-size: 11px; 
 
} 
 

 
.menu li { 
 
    list-style-type: none; 
 
} 
 

 
.menu li.active { 
 
    font-weight: bold; 
 
} 
 

 
#sidebar { 
 
    background: #2a2c36; 
 
    color: #eee; 
 
    position: fixed; 
 
    height: 100%; 
 
    width: 250px; 
 
    overflow: hidden; 
 
    left: 0; 
 
    margin: 0; 
 
} 
 

 
#wrapper { 
 
    margin: 0 0 0 250px; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>The World</title> 
 
    <meta charset="utf-8" /> 
 
    <link rel="stylesheet" href="css/site.css" /> 
 

 
</head> 
 

 
<body> 
 
    <div id="sidebar"> 
 
    <img src="img/user1.jpg" alt="Headshot" class="Headshot" /> 
 
    <span>Sam Hastings </span> 
 
    <ul class="menu"> 
 
     <li class="active"><a href="#">Home</a></li> 
 
     <li><a href="#">About</a></li> 
 
     <li><a href="#">Contact</a></li> 
 
    </ul> 
 
    </div> 
 
    <div id="wrapper"> 
 
    <div id="main"> 
 
     <h3>The World</h3> 
 
     <p>Ofineo website</p> 
 
     <form> 
 
     <div> 
 
      <label>Date</label> 
 
      <input /> 
 
     </div> 
 
     <div> 
 
      <label>Location</label> 
 
      <input /> 
 
     </div> 
 
     <div> <input type="submit" value="add" /></div> 
 
     </form> 
 
    </div> 
 
    <div id="footer"> 
 
     &copy; 2015 the world Ltd. 
 
    </div> 
 
    </div> 
 

 
</body> 
 

 
</html>

0

を追加で置き換えから#mainに変更してください。

/* site.css */ 
 

 
body{ 
 
    font-family:sans-serif; 
 
    font-size: 14px; 
 
    margin:0; 
 
} 
 
label{ 
 
    font-weight:bold; 
 
    display:block; 
 
} 
 
input[type=text], input[type=password], textarea{ 
 
    width:150px; 
 
} 
 

 
#main{ 
 
    background-color: #eee; 
 
    padding:4px; 
 
    margin-left:250px; 
 
} 
 
#footer{ 
 
    background-color:#222; 
 
    color:#eee; 
 
    padding:8px 4px; 
 
    position:fixed; 
 
    width:100%; 
 
    bottom:0; 
 
} 
 
.Headshot{ 
 
    max-width: 50px; 
 
    border: 1px solid #222; 
 
    padding: 3px; 
 
    
 
} 
 

 
.menu{ 
 
    font-size:11px; 
 
} 
 

 
.menu li{ 
 
    list-style-type: none; 
 
} 
 

 
.menu li.active { 
 
    font-weight:bold; 
 
} 
 
#sidebar { 
 
    background:#2a2c36; 
 
    color:#eee; 
 
    position:fixed; 
 
    height:100%; 
 
    width:250px; 
 
    overflow:hidden; 
 
    left:0; 
 
    margin:0; 
 
} 
 

 
#wrapper{ 
 
    left:0 0 0 250px; 
 
} 
 
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <title>The World</title> 
 
    <meta charset="utf-8" /> 
 
    <link rel="stylesheet" href="css/site.css" /> 
 

 
</head> 
 
<body> 
 
    <div id="sidebar"> 
 
     <img src="img/user1.jpg" alt="Headshot" class="Headshot"/> 
 
     <span>Sam Hastings </span> 
 
     <ul class="menu"> 
 
      <li class="active"><a href="#" >Home</a></li> 
 
      <li><a href="#">About</a></li> 
 
      <li><a href="#">Contact</a></li> 
 
     </ul> 
 
    </div> 
 
    <div id="wrapper"> 
 
     <div id="main"> 
 
      <h3>The World</h3> 
 
      <p>Ofineo website</p> 
 
      <form> 
 
       <div> 
 
        <label>Date</label> 
 
        <input /> 
 
       </div> 
 
       <div> 
 
        <label>Location</label> 
 
        <input /> 
 
       </div> 
 
       <div> <input type="submit" value="add" /></div> 
 
      </form> 
 
     </div> 
 
     <div id="footer"> 
 
      &copy; 2015 the world Ltd. 
 
     </div> 
 
    </div> 
 

 
</body> 
 
</html>

代わりに `left`
関連する問題