Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [CSS]Problem ze zbyt długim divem
Forum PHP.pl > Forum > Przedszkole
AboutMe
Witam,

Czy ktoś wie dlaczego pierwszy post zawsze się rozszerza do długości sidebara?



  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  5.  
  6.  
  7.  
  8. body {
  9. margin:0;
  10. padding:0;
  11. background: black;
  12. width: 100%;
  13. }
  14.  
  15.  
  16. #general {
  17. width: 1300px; height: auto;
  18. }
  19. #sidebar {
  20. padding: 10px 10px 0px 0px;
  21. float: left;
  22. width: 180px;
  23. }
  24.  
  25. .sidebar-box {
  26. margin-top: 20px;
  27. margin-left: 0px;
  28. padding: 0px 0px 20px 0px;
  29. width: 160px; height: auto;
  30. border: 1px solid #626262;
  31. font: 11pt Verdana, Arial, sans-serif;
  32. color: #c3c3c3;
  33. background: black;
  34. background-repeat: repeat-y;
  35. }
  36.  
  37. .sidebar-box li {
  38. margin-left: 10px;
  39. margin-top: 5px;
  40. }
  41.  
  42. .sidebar-box-title {
  43. border-bottom: 1px solid #626262;
  44. padding: 0px 0px 5px 10px;
  45. }
  46.  
  47. #content {
  48. width: 660px;
  49. margin-top: 20px;
  50. margin-left: 200px;
  51. padding: 10px 10px 10px 10px;
  52. font: 9pt Verdana, Arial, sans-serif;
  53. color: #c3c3c3;
  54. }
  55.  
  56. .post {
  57. width: 670px;
  58. margin-top: 23px;
  59. padding: 10px 10px 10px 10px;
  60. background: black;
  61. text-align: justify;
  62. border: 1px solid #626262;
  63. }
  64.  
  65.  
  66.  
  67. .clear {
  68. clear: both;
  69. }
  70.  
  71.  
  72. .post-title{
  73. font: 22pt Verdana, Arial, sans-serif;
  74. }
  75.  
  76. .text {
  77. width: 540px;
  78. float: left;
  79. padding: 10px 3px 10px 0px;
  80. }
  81.  
  82. .more-link {
  83. font: 16pt Verdana, Arial, sans-serif;
  84. padding: 15px;
  85. margin-top: 20px;
  86. }
  87.  
  88. .info {
  89. width: 100px;
  90. float: right;
  91. font: 7pt Verdana, Arial, sans-serif;
  92. text-align: left;
  93. border-left: 1px dotted #626262;
  94. padding: 15px 3px 10px 10px;
  95. }
  96.  
  97.  
  98. .date {
  99. font: 9pt Arial, Verdana, sans-serif;
  100. color: white;
  101. }
  102.  
  103. .time {
  104. font-size: 15pt;
  105. color: white;
  106. }
  107.  
  108.  
  109.  
  110.  
  111. </head>
  112.  
  113.  
  114.  
  115. <div id="general">
  116.  
  117. <div id="sidebar">
  118.  
  119. <div class="sidebar-box">
  120.  
  121. <div class="sidebar-box-title"><h3>Categories</h3></div><!--categories ends-->
  122.  
  123.  
  124. <li class="cat-item cat-item-23"><a href="23" title="View all posts filed under ac">ac</a> (3)
  125. </li>
  126. <li class="cat-item cat-item-3"><a href="3" title="View all posts filed under Aenean">Aenean</a> (4)
  127.  
  128. </li>
  129. <li class="cat-item cat-item-28"><a href="28" title="View all posts filed under aliquam">aliquam</a> (3)
  130. </li>
  131. <li class="cat-item cat-item-24"><a href="24" title="View all posts filed under ante">ante</a> (2)
  132. </li>
  133. <li class="cat-item cat-item-4"><a href="4" title="View all posts filed under Blandit">Blandit</a> (4)
  134. </li>
  135. <li class="cat-item cat-item-11"><a href="11" title="View all posts filed under Egestas">Egestas</a> (3)
  136.  
  137. </li>
  138. <li class="cat-item cat-item-26"><a href="26" title="View all posts filed under faucibus">faucibus</a> (3)
  139. </li>
  140. <li class="cat-item cat-item-7"><a href="7" title="View all posts filed under Imperdiet">Imperdiet</a> (2)
  141. </li>
  142. <li class="cat-item cat-item-5"><a href="5" title="View all posts filed under Ligula">Ligula</a> (4)
  143. </li>
  144. <li class="cat-item cat-item-30"><a href="30" title="View all posts filed under mattis">mattis</a> (2)
  145.  
  146. </li>
  147. <li class="cat-item cat-item-6"><a href="6" title="View all posts filed under Mauris">Mauris</a> (4)
  148. </li>
  149. <li class="cat-item cat-item-20"><a href="20" title="View all posts filed under Nam">Nam</a> (2)
  150. </li>
  151. <li class="cat-item cat-item-27"><a href="27" title="View all posts filed under nibh">nibh</a> (1)
  152. </li>
  153. <li class="cat-item cat-item-25"><a href="25" title="View all posts filed under Pellentesque">Pellentesque</a> (1)
  154.  
  155. </li>
  156.  
  157.  
  158.  
  159. </div><!--sidebar-box ends-->
  160.  
  161.  
  162.  
  163. </div><!--sidebar ends-->
  164.  
  165.  
  166. <div id="content">
  167.  
  168.  
  169.  
  170. <div class="post">
  171. <div class="text">
  172.  
  173. <h2><a href="?p=30" rel="bookmark" title="Fixed link Tristique">Tristique</a></h2>
  174.  
  175.  
  176. <p>Suspendisse lacinia est in diam lobortis at aliquet leo dignissim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam et ipsum nisl. Mauris congue, erat id pellentesque suscipit, nulla libero vulputate ipsum, eu suscipit nibh lorem nec velit. Aenean lacinia tincidunt ultrices. <br />
  177. <a href="?p=30#more-30" class="more-link">Read more ></a></p>
  178.  
  179. <div style="float:right"><h5><p><a href="?p=30#comments" title="Comment on Tristique">2 Comments ?</a></p></h5></div>
  180. </div><!--text-->
  181.  
  182. <div class="info">
  183. <img src="photo.png" alt="Photo" width="85" height="80" />
  184. <p><h4>Posted by admin</h4>
  185. <h4>April 3rd</h4>
  186.  
  187. <h4>2010</h4>
  188. <span class="time">19:58</span>
  189.  
  190. <h6>Under:<br />
  191. <a href="5" title="View all posts in Ligula" rel="category">Ligula</a><br /> <a href="6" title="View all posts in Mauris" rel="category">Mauris</a><br /> <a href="24" title="View all posts in ante" rel="category">ante</a><br /> <a href="26" title="View all posts in faucibus" rel="category">faucibus</a></h6>
  192. </div><!--info-->
  193.  
  194. <div class="clear">
  195.  
  196.  
  197. </div>
  198.  
  199. </div><!--post-->
  200.  
  201.  
  202.  
  203. <div class="post">
  204. <div class="text">
  205.  
  206. <h2><a href="?p=28" rel="bookmark" title="Fixed link Quisque">Quisque</a></h2>
  207.  
  208.  
  209. <p>Suspendisse lacinia est in diam lobortis at aliquet leo dignissim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam et ipsum nisl. <br />
  210. <a href="?p=28#more-28" class="more-link">Read more ></a></p>
  211.  
  212. <div style="float:right"><h5><p><a href="?p=28#respond" title="Comment on Quisque">No Comments ?</a></p></h5></div>
  213. </div><!--text-->
  214.  
  215. <div class="info">
  216. <img src="photo.png" alt="Photo" width="85" height="80" />
  217. <p><h4>Posted by admin</h4>
  218. <h4>April 3rd</h4>
  219. <h4>2010</h4>
  220.  
  221. <span class="time">9:57</span>
  222.  
  223. <h6>Under:<br />
  224. <a href="3" title="View all posts in Aenean" rel="category">Aenean</a><br /> <a href="4" title="View all posts in Blandit" rel="category">Blandit</a></h6>
  225. </div><!--info-->
  226.  
  227.  
  228. <div class="clear">
  229.  
  230.  
  231. </div>
  232.  
  233. </div><!--post-->
  234.  
  235.  
  236.  
  237. <div class="post">
  238. <div class="text">
  239.  
  240. <h2><a href="?p=26" rel="bookmark" title="Fixed link Info">Info</a></h2>
  241.  
  242.  
  243. <p>Suspendisse lacinia est in diam lobortis at aliquet leo dignissim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam et ipsum nisl. <br />
  244. <a href="?p=26#more-26" class="more-link">Read more ></a></p>
  245.  
  246. <div style="float:right"><h5><p><a href="?p=26#respond" title="Comment on Info">No Comments ?</a></p></h5></div>
  247. </div><!--text-->
  248.  
  249. <div class="info">
  250. <img src="photo.png" alt="Photo" width="85" height="80" />
  251. <p><h4>Posted by admin</h4>
  252. <h4>April 3rd</h4>
  253. <h4>2010</h4>
  254. <span class="time">9:57</span>
  255.  
  256. <h6>Under:<br />
  257.  
  258. <a href="11" title="View all posts in Egestas" rel="category">Egestas</a><br /> <a href="6" title="View all posts in Mauris" rel="category">Mauris</a><br /> <a href="23" title="View all posts in ac" rel="category">ac</a><br /> <a href="28" title="View all posts in aliquam" rel="category">aliquam</a></h6>
  259. </div><!--info-->
  260.  
  261.  
  262. <div class="clear">
  263.  
  264.  
  265. </div>
  266.  
  267. </div><!--post-->
  268.  
  269.  
  270.  
  271. <div class="post">
  272. <div class="text">
  273.  
  274. <h2><a href="?p=22" rel="bookmark" title="Fixed link Etiam sodales fringilla">Etiam sodales fringilla</a></h2>
  275.  
  276.  
  277. <p>Integer ligula nisi, condimentum vel vestibulum et, ornare ut enim. Morbi mattis velit purus. Sed ultrices neque in turpis suscipit non malesuada justo ornare. Proin vel egestas tortor.<br />
  278. <a href="?p=22#more-22" class="more-link">Read more ></a></p>
  279.  
  280. <div style="float:right"><h5><p><a href="?p=22#respond" title="Comment on Etiam sodales fringilla">No Comments ?</a></p></h5></div>
  281.  
  282. </div><!--text-->
  283.  
  284. <div class="info">
  285. <img src="photo.png" alt="Photo" width="85" height="80" />
  286. <p><h4>Posted by admin</h4>
  287. <h4>April 3rd</h4>
  288. <h4>2010</h4>
  289. <span class="time">7:34</span>
  290.  
  291. <h6>Under:<br />
  292. <a href="4" title="View all posts in Blandit" rel="category">Blandit</a><br /> <a href="20" title="View all posts in Nam" rel="category">Nam</a><br /> <a href="23" title="View all posts in ac" rel="category">ac</a><br /> <a href="28" title="View all posts in aliquam" rel="category">aliquam</a><br /> <a href="26" title="View all posts in faucibus" rel="category">faucibus</a><br /> <a href="30" title="View all posts in mattis" rel="category">mattis</a></h6>
  293.  
  294. </div><!--info-->
  295.  
  296.  
  297. <div class="clear">
  298.  
  299.  
  300. </div>
  301.  
  302. </div><!--post-->
  303.  
  304.  
  305.  
  306. <div style="display:inline">
  307. <h5><div style="float:left"><a href="?paged=2" ><<< Older Entries</a></div>
  308.  
  309. <div style="float:right"></div></h5>
  310. </div>
  311.  
  312.  
  313.  
  314. </div><!--content ends-->
  315.  
  316. <div class="clear">
  317.  
  318.  
  319. </div>
  320. </div>
  321. </div><!--general ends-->
Skie
Pokaż lepiej wersje LIVE, bo tak samego tekstu to mało kto się podejmie przy poprawianiu.
AboutMe
Przecież wystarczy pobrać plik rozszerzeniem html i masz live
mortus
A w jakiej przeglądarce, bo u mnie jest w porządku, chociaż jest parę błędów:
1. w każdym div-ie info nie zamykasz znacznika <p>
2. w linii 311 używasz <<<, i to powoduje pewne błędy.
hieroshima
Spróbuj dać do diva id sidebar position: absolute; to będzie wyglądać tak:

#sidebar
{
position: absolute;
padding: 10px 10px 0px 0px;
float: left;
width: 180px;
}
AboutMe
Pod IE działa, tylko z FF i Operą jest problem.

Absolute nie wchodzi w grę bo strona jest centrowana.
hieroshima
co z tego, że jest centrowana? nic sie nie stanie z tym sidebarem sprawdzalem pod IE FF i Opera i bylo ok
AboutMe
To zmień rozdzielczość ekranu i zobaczysz czemu.
krzysztof_kf
Cytat(AboutMe @ 6.04.2010, 13:55:27 ) *
Witam,

Czy ktoś wie dlaczego pierwszy post zawsze się rozszerza do długości sidebara?




Hmm może dodaj jakąś szerokość dla akapitu p np

  1.  
  2. .text p {
  3. width: 500px;


jak ma ci się takie coś nie rozszerzać ? bez jakiejś wartości ...
pedro84
1. Kod słabej jakości
2. Po co dajesz pakujesz nagłówki w divy?
3. #general jest za długi, przy mniejszych rozdzielczościach się wywala.

Co Ci właściwie nie działa?
AboutMe
Chodzi mi o rozszerzanie w pionie.
1. post rozszerza się w pionie do długości sidebara.
Gdy mam w lewym sidebarze więcej elementów to 1. post potrafi być długi na tysiące pixeli.

Podejrzewam że to przez float:left



Co do nagłówków w divach to niestety jak dam span to nie działa
border-bottom: 1px solid #626262;
zegarek84
Cytat(AboutMe @ 7.04.2010, 13:26:22 ) *
Podejrzewam że to przez float:left

to nie podejrzewaj tylko zmień/usuń deklarację a przekonasz się, że tak jest...
Cytat(AboutMe @ 6.04.2010, 15:28:30 ) *
Pod IE działa, tylko z FF i Operą jest problem.

Absolute nie wchodzi w grę bo strona jest centrowana.

akurat IE nie mam pod ręką ale centrowania w podanym przykładzie przez Ciebie też nie ma w mozilli i operze bez żadnych dodatkowych deklaracji ;p

po za tym przez absolute też da się centrować - trzeba tylko pomyśleć..

rozwiązanie na zadane pytanie dostałeś
w tym poście - czego w ogóle Ty jeszcze chcesz??
mortus
Witam. Żeby wszystko było w porządku wcale nie trzeba kombinować, wystarczy zmienić styl div-a o identyfikatorze content na taki:
  1. #content {
  2. width: 660px;
  3. margin-top: 20px;
  4. padding: 10px 10px 10px 10px;
  5. font: 9pt Verdana, Arial, sans-serif;
  6. color: #c3c3c3;
  7. float: left;
  8. }
Jednak na stronie jest dużo więcej błędów. Wrzuć sobie kod do walidatora XHTML to zobaczysz. Podstawowe to:
1. brak znaczników <title> i </title> w sekcji head,
2. brak znacznika rozpoczynającego i kończącego listę <ul> i </ul>, są natomiast same elementy listy <li> i </li>,
3. umieszczenie akapitów (<p>...</p>) wewnątrz nagłówków (<h5> i </h5>),
4. obejmowanie nagłówków <h4>....</h4> akapitami <p>...</p>,
5. używanie <<< zamiast odpowiednich encji,
6. umieszczenie div-a wewnątrz nagłówka <h5>...</h5>.
AboutMe
float: left; dla #content nic nie daje,
a przez absolute sidebar najeżdża mi na footer, jeśli content jest krótszy od sidebara.
mortus
Cytat(AboutMe @ 11.04.2010, 16:29:29 ) *
float: left; dla #content nic nie daje
A usunąłeś margin-left: 200px;?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.