我刚刚完成了一个主题的编码,除了一件事,编码和整体外观都很棒。因此,当我进入收件箱页面或内容短于整体侧边栏高度的任何页面时,我的侧边栏div似乎超出了我的容器div。这是一个例子 image。 这是编码结构css& HTML
.sidebar {
width:310px;
margin-top:30px;
margin-left: 590px;
position: absolute;
.wrap {
width: 920px;
margin: 0 auto;
background:{color:content background};
padding: 20px 20px 0px 20px;
margin-top: -5px;
position: relative;
}
.content {
margin-top:30px;
width: 500px;
margin-left:20px;
}
<div class="wrap"> <!--CONTAINER-->
<div class="topbar"> <!--TOP LINKS-->
<div id="title">{title}</div>
<div class="links">
<a href="/">Home</a>
<a href="/ask">Inbox</a>
<a href="/archive">Archive</a>
<a href="{text:link 1 url}">{text:link 1 title}</a>
<a href="{text:link 2 url}">{text:link 2 title}</a>
<!--DO NOT REMOVE CREDIT!!!-->
<a href="http://ixaathemes.tumblr.com/">Theme</a>
<!--DO NOT REMOVE CREDIT!!!-->
</div> <!--TOP LINKS-->
</div>
<div class="header">
<img src="{image:header}">
</div>
<div class="sidebar"> <!--SIDEBAR CONTENT. THIS IS WHERE THE SIDEBOXES ARE WHERE YOU CAN MANUALLY ADD THE CONTENTS-->
<!-- DESCRIPTION BOX -->
<div class="cat">
<div class="cti"><i class="fa fa-user" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Welcome</div>
<div class="sideimg"><img src="{image:sidebar}"></div>
<div class="description">{Description}</div>
</div>
<!-- NAVIGATION LINKS -->
{block:ifextralinks}
<div class="cat">
<div class="cti"><i class="fa fa-list" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Navigation Links</div>
<div class="morelinks">
{block:ifCustomLink1}<a href="{text:CustomLink1URL}">{text:CustomLink1Name}</a>{/block:ifCustomLink1}
{block:ifCustomLink2}<a href="{text:CustomLink2URL}">{text:CustomLink2Name}</a>{/block:ifCustomLink2}
{block:ifCustomLink3}<a href="{text:CustomLink3URL}">{text:CustomLink3Name}</a>{/block:ifCustomLink3}
{block:ifCustomLink4}<a href="{text:CustomLink4URL}">{text:CustomLink4Name}</a>{/block:ifCustomLink4}
{block:ifCustomLink5}<a href="{text:CustomLink5URL}">{text:CustomLink5Name}</a>{/block:ifCustomLink5}
{block:ifCustomLink6}<a href="{text:CustomLink6URL}">{text:CustomLink6Name}</a>{/block:ifCustomLink6}
</div>
</div>
{/block:ifextralinks}
<!-- UPCOMING EVENTS -->
{block:ifevents}
<div class="cat">
<div class="cti"><i class="fa fa-calendar" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Upcoming events</div>
<div class="events">
<!-- THIS IS WHERE YOU WILL ADD YOUR UPCOMING EVENTS IF YOU PLEASE. if you would like to add more just copy the code below:
<tr>
<td>
<div class="date">Event date here</div>
</td>
<td>
<div class="e">Event info here</div>
</td>
</tr>
make sure to past it right about the 'event end'
-->
<table style="width:100%">
<!-- events box start -->
<tr>
<td>
<div class="date">November 12</div>
</td>
<td>
<div class="e">Event: One</div>
</td>
</tr>
<tr>
<td>
<div class="date">November 13</div>
</td>
<td>
<div class="e">Event: two</div>
</td>
</tr>
<tr>
<td>
<div class="date">November 14</div>
</td>
<td>
<div class="e">Event: three</div>
</td>
</tr>
<tr>
<td>
<div class="date">November 14</div>
</td>
<td>
<div class="e">Event: four</div>
</td>
</tr>
<!-- events box start -->
</table>
</div></div>
{/block:ifevents}
<!-- PROJECTS -->
{block:ifprojects}
<div class="cat">
<div class="cti"><i class="fa fa-book" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Projects</div>
<div class="projects">
<!-- THIS IS WHERE YOU WILL ADD THE PROJECTS THAT CORRESPOND WITH THE THEME OF YOUR FANSITE BLOG. iF YOU WOULD LIKETO ADD MORE JUST COPY THE CODE BELOW:
<tr>
<td style="width:30px">
<img src="IMAGE URL">
</td>
<td>
<div class="pinfo">
<b>Title:</b><br>
<l1>
<b>Info</b>: Info<br>
<b>Info</b>: Info<br>
<b>Info</b>: Info</div>
</l1>
</td>
</tr>
MAKE SURE TO PASTE IT RIGHT ABOVE THE 'PROJECTS END'
-->
<table style="margin-top:0px; width:100%">
<!-- PROJECTS START-->
<tr>
<td style="width:30px">
<img src="http://static.tumblr.com/pbhn8p5/BPwo9x2yv/ject-5.png">
</td>
<td>
<div class="pinfo">
<b>Title:</b><br>
<l1>
<b>Info</b>: Info<br>
<b>Info</b>: Info<br>
<b>Info</b>: Info</div>
</l1>
</td>
</tr>
<tr>
<td style="width:30px">
<img src="http://static.tumblr.com/pbhn8p5/AoQo9x30n/ject-6.png">
</td>
<td>
<div class="pinfo">
<b>Title:</b><br>
<l1>
<b>Info</b>: Info<br>
<b>Info</b>: Info<br>
<b>Info</b>: Info</div>
</l1>
</td>
</tr>
<tr>
<td style="width:30px">
<img src="http://static.tumblr.com/pbhn8p5/t5so9x315/ject-7.png">
</td>
<td>
<div class="pinfo">
<b>Title:</b><br>
<l1>
<b>Info</b>: Info<br>
<b>Info</b>: Info<br>
<b>Info</b>: Info</div>
</l1>
</td>
</tr>
<!-- PROGECTS END-->
</table>
</div></div>
{/block:ifprojects}
<!-- MEMBERS -->
{block:ifmembers}
<div class="cat">
<div class="cti"><i class="fa fa-users" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Members</div>
<!-- THIS IS BASICALLY SET UP FOR A GROUP BLOG SCENARIO. BASICALLY THE BLOGGER (YOU) GIVE PERMISSION FOR OTHER PEOPLE TO HAVE ACCESS TO THIS BLOG. FOR MORE INFORMATION ON HOW TO SET THIS UP CHECK OUT THIS WEBSITE BELOW
http://smallbusiness.chron.com/set-up-admins-tumblr-34947.html
SO TO PUT IT SIMPLY YOU DON'T EDIT THIS BOX LIKE YOU WOULD THE OTHERS UNLESS YOU KNOW WHAT YOU'RE DOING.
-->
{block:GroupMembers}
<table style="margin-top:0px; padding: 10px;">
{block:GroupMember}
<tr>
<td style="width:40px;">
<img src="{GroupMemberPortraitURL-40}" width="40px;" height="40px;" style="margin-right: 10px; padding:5px;">
</td>
<td style="width:290px; height:auto;">
<div id="m" style="margin-bottom:10px;">
<a href="{GroupMemberURL}" style="color:{color:desc link};">{GroupMemberName}</a><br>{GroupMemberTitle}</div>
</tr>
{/block:GroupMember}
</table>
{/block:GroupMembers}
</div>
{/block:ifmembers}
<!-- UPDATES BOX -->
{block:ifupdates}
<div class="cat">
<div class="cti"><i class="fa fa-pencil" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Updates</div>
<div class="up">
<!-- THIS IS THE UPDATES TAP WHERE YOU CAN PLACE ALL OF YOUR RECORDS OF YOUR RECENT BLOG-RELATED UPDATES. IF YOU WOULD LIKE TO ADD MORE UPDATES THEN YOU CAN JUST COPY THE CODE BELOW:
<tr>
<td><div class="update">date</div></td>
<td><div class="upinfo">update</div></td>
</tr>
MAKE SURE TO PASTE THE CODE RIGHT ABOUT THE 'UPDATES END'
-->
<table style="width:100%">
<!-- UPDATES START -->
<tr>
<td><div class="update">11.12:</div></td>
<td><div class="upinfo">update one</div></td>
</tr>
<tr>
<td><div class="update">11.13:</div></td>
<td><div class="upinfo">update one</div></td>
</tr>
<tr>
<td><div class="update">11.14:</div></td>
<td><div class="upinfo">update one</div></td>
</tr>
<tr>
<td><div class="update">11.15:</div></td>
<td><div class="upinfo">update one</div></td>
</tr>
<!-- UPDATES END -->
</table>
</div>
</div>
{/block:ifupdates}
<!-- AFFILIATES -->
{block:ifaffiliates}
<div class="cat">
<div class="cti"><i class="fa fa-laptop" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Affiliates</div>
<div class="affiliates">
<!-- THIS IS WHERE YOU CAN ADD THE IMAGES OF THE SISTER BLOG IN WHICH YOUR FANSITE IS AFFILIATED WITH. IF YOU WOULD LIKE TO ADD MORE PICTURES THEN JUST CODY THE CODE BELOW
<a href="/" title="visit blog"><img src="IMAGE URL"/></a>
MAKE SURE TO PASTE THE CODE RIGHT ABOVE THE 'AFFILIATES END'
-->
<!-- AFFILIATES START-->
<a href="/" title="apply"><img src="http://static.tumblr.com/7r3q3uq/MmIo6iq7n/ject-1.png"/></a>
<a href="/" title="apply"><img src="http://static.tumblr.com/7r3q3uq/lado6ipym/ject-2.png"/></a>
<a href="/" title="apply"><img src="http://static.tumblr.com/7r3q3uq/QrJo6ipyy/ject-3.png"/></a>
<a href="/" title="apply"><img src="http://static.tumblr.com/7r3q3uq/L0Mo6ipz9/ject-4.png"/></a>
<!-- AFFILIATES END-->
</div>
</div>
{/block:ifaffiliates}
<!-- OFFICIAL LINKS -->
{block:ifofficiallinks}
<div class="cat">
<div class="cti"><i class="fa fa-globe" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>Official Links</div>
<div class="off">
<!-- THEM OFFICIAL LINKS WHICH ARE ALREADY SET UP FOR YOU IN THE EDIT THEME SECTION DO NOT CHANGE ANYTHING BELOW. -->
<a href="{text:official link 1 url}">{text:official link 1 title} <i class="fa fa-twitter" style="float:right; color:{color:navi};"></i></a>
<a href="{text:official link 2 url}">{text:official link 2 title} <i class="fa fa-instagram" style="float:right; color:{color:navi};"></i></a>
<a href="{text:official link 3 url}">{text:official link 3 title} <i class="fa fa-facebook" style="float:right; color:{color:navi};"></i></a>
<a href="{text:official link 4 url}">{text:official link 4 title} <i class="fa fa-snapchat-ghost" aria-hidden="true" style="float:right; color:{color:navi};"></i></a>
<a href="{text:official link 5 url}">{text:official link 5 title} <i class="fa fa-youtube-play" style="float:right; color:{color:navi};"></i></a>
</div>
</div>
{/block:ifofficiallinks}
<!-- BLOG INFO -->
{block:ifbloginfo}
<div class="cat">
<div class="cti"><i class="fa fa-check" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>About this blog</div>
<div class="binfo">
<!-- GENER BLOG INFO LIKE WHEN WAS IT ESTABLISHED. YOUR FREE HOSTED SCRIPTS (ONLINE USERS, BLOG VISITS, FOLLOWERS/ETC. -->
<b>About:</b> A fansite theme for fandom challenges, character, shipss, whatever floats your boat <br>
<b>Admins:</b> 1 <br>
<b>Designed by:</b> <a href="http://ixathemes.tumblr.com">ixathemes</a> @ tumblr<br>
<b>Online:</b> <script language="JavaScript">
var ref = (''+document.referrer+'');
var w_h = window.screen.width + " x " + window.screen.height;
document.write('<script src="http://s1.freehostedscripts.net/ocounter.php?site=ID4973001&e1=ghoul &e2=ghouls &r=' + ref + '&wh=' + w_h + '"><\/script>');
</script> <br>
<b>Visits:</b> <script language="JavaScript" src="http://s1.freehostedscripts.net/ocount.php?site=ID2955028&name=investigators"></script><br><br>
This site claims no credit for any images posted unless it's been stated otherwise. Images and information posted on this blog are copyrighted to their respective owners.
</div>
</div>
{/block:ifbloginfo}
<!-- Search Bar -->
{block:ifsearch}
<div class="cat">
<div class="cti"><i class="fa fa-search" aria-hidden="true" style="padding-right:10px; color:{color:titles};"></i>search</div>
<div class="bsearch">
<!-- THIS IS SEARCHBAR CODE. DO NOT TOUCH PLEASE. -->
<script language="javascript">
function send()
{document.theform.submit()}
</script>
<form action="/search" method="get" class="sfm">
<input type="text" name="q" value="search" id="sf"/>
<input type="image" value="Search" src="http://static.tumblr.com/f1skqpy/Oxbn13qun/search_icon.png" id="sb"/>
</form>
<!-- THIS IS SEARCHBAR CODE. DO NOT TOUCH PLEASE. -->
</div>
</div>
{/block:ifsearch}
<!-- Search Bar -->
</div> <!--SIDEBAR-->
<div class="content"> <!--CONTENT-->
{block:Posts}
<div class="posts"> <!--POSTS-->
{block:ContentSource}
<!-- {SourceURL}{block:SourceLogo}<img src="{BlackLogoURL}"
width="{LogoWidth}" height="{LogoHeight}" alt="{SourceTitle}" />
{/block:SourceLogo}
{block:NoSourceLogo}{SourceLink}{/block:NoSourceLogo} -->
{/block:ContentSource}
<!-- {block:NoRebloggedFrom}
{block:RebloggedFrom}{ReblogParentName}{/block:RebloggedFrom}
{/block:NoRebloggedFrom} -->
{block:Text}
{block:Title}<div class="title">{Title}</div>{/block:Title}
<div class="text">{Body}</div>
{/block:Text}
{block:Photo}
{LinkOpenTag}<img src="{PhotoURL-500}" width="500">{LinkCloseTag}
{/block:Photo}
{block:Photoset}
{Photoset-500}
{/block:Photoset}
{block:Quote}
<center>
<div class="quote-box">"</div>
</center>
<div class="qtline"></div>
<div class="quote">{Quote}</div>
{block:Source}<div class="qtsource"><br><center>- {Source} -</center></div>{/block:Source}
{/block:Quote}
{block:Link}
<div class="link"><a href="{URL}">{Name} »</a></div>
{block:Description}
<div class="text">{Description}</div>
{/block:Description}
{/block:Link}
{block:Chat}
{block:Title}<h1>{Title}</h1>{/block:Title} <div class="chat"> {block:Lines} <li class="line {Alt}"> {block:Label} <span class="label"> {Label}</span> {/block:Label}{Line}</li> {/block:Lines}</div>
{/block:Chat}
{block:Audio}
<div class="playbox"><div class="playbutton">{block:AudioPlayer}{AudioPlayerWhite}{/block:AudioPlayer}</div></div>
{block:AlbumArt}
<img src="{AlbumArtURL}" class="cover">
{/block:AlbumArt}
<div class="trackdetails"><br>
{block:TrackName}<b>Track:</b> {TrackName}{/block:TrackName}<br>
{block:Artist}<b>Artist:</b> {Artist}{/block:Artist}<br>
{block:Album}<b>Album:</b> {Album}{/block:Album}<br>
{block:PlayCount}<b>Played:</b> {PlayCountWithLabel}{/block:PlayCount}
</div>
{/block:Audio}
{block:Video}
{Video-500}
{/block:Video}
{block:Answer}
<div id="asker"><b>{Asker} asked:</b></div>
<img src="{AskerPortraitURL-64}"align="left" style="border:5px solid {color:asker portrait border}">
<div class="question">
{Question} </div>
<div class="answer">{Answer}</div>
{/block:Answer}
{block:IfShowCaptions}{block:Caption}<div class="text">{Caption}</div>{/block:Caption}{/block:IfShowCaptions}
{block:IfnotShowCaptions}
{block:PermalinkPage}{block:Caption}<div class="text">{Caption}</div>{/block:Caption}{/block:PermalinkPage}{/block:IfnotShowCaptions}
{block:IndexPage}
<div class="info"> <!--Permalink and Notes-->
Posted
{block:Date}
<a href="{Permalink}" title="{TimeAgo}">{Month} {DayOfMonth}{DayOfMonthSuffix}</a>
{/block:Date}
{block:NoteCount} with <a href="{Permalink}" title="go to permalink page">{NoteCountWithLabel}</a>{/block:NoteCount}
<font style="float:right">
{block:RebloggedFrom}
<a href="{ReblogParentURL}" title="{ReblogParentName}">via </a>
{block:ContentSource}
<a href="{ReblogRootURL}" "{ReblogRootName}" title="{ReblogRootName}">| src</a>
{/block:ContentSource}
|
{/block:RebloggedFrom}
<a href="{ReblogURL}" title="Reblog this post"> reblog</a>
</font style>
</div> <!--Permalink and Notes-->
<!--TAGS-->
{block:ifShowTags}
{block:HasTags}<div id="tag">{block:Tags}<a href="{TagURL}" title="Tagged as">#{tag}</a> {/block:Tags}</div>{/block:HasTags}{/block:ifShowTags}
{block:permalinkpage}{block:ifnotShowTags}{block:HasTags}<div id="tag"> {block:Tags}<a href="{TagURL}" title="Tagged as">#{Tag}</a>{/block:Tags}</div>{/block:HasTags}{/block:ifnotShowTags}{/block:permalinkpage}
<!--TAGS-->
{/block:IndexPage}
</div> <!--CONTENT-->
{block:PermalinkPage} <!--PERMALINK PAGE-->
<div id="perma">
{block:Date}Posted {ShortMonth} {DayOfMonthWithZero}, {Year} @ {12Hour} {AmPm}{/block:Date}
{block:NoteCount}with {NoteCountWithLabel}{/block:NoteCount}{block:RebloggedFrom}
<br>
<a href="{ReblogParentURL}">via: {ReblogParentName}</a> +
<a href="{ReblogRootURL}">source: {ReblogRootName}</a>
{/block:RebloggedFrom}
<br>
{block:HasTags}{block:Tags}<a href="{TagURL}" title="Tagged as">#{Tag}</a> {/block:Tags}{/block:HasTags}
</div>
{block:PostNotes}
{PostNotes}
{/block:PostNotes}
{/block:PermalinkPage}
{/block:Posts} <!--PERMALINK PAGE-->
<div id="foot"> <!--PAGINATION BAR-->
<!--pagination-->
{block:IfNotInfiniteScroll}
{block:Pagination}
<div id="pagination">
{block:PreviousPage}<a href="{PreviousPage}">«</a>{/block:PreviousPage}
{block:JumpPagination length="5"}
{block:CurrentPage}<span class="current_page">X</span>{/block:CurrentPage}
{block:JumpPage}<a href="{URL}">{PageNumber}</a> {/block:JumpPage}
{/block:JumpPagination}
{block:NextPage}<a href="{NextPage}">»</a>{/block:NextPage}
</div>
{/block:Pagination}
{/block:IfNotInfiniteScroll}
<!--pagination-->
</div> <!--PAGINATION BAR-->
</div> <!--CONTAINER-->
所以我想知道有没有办法让我解决这个问题,因为我是一个主题制作者,我有人来到我的收件箱中关于这个问题,我讨厌回答说我不知道,哪个可以导致他们放弃主题,因为我不知道如何修复设计缺陷。非常感谢你:)
以下是完整代码pastebin code。
答案 0 :(得分:0)
将body和html的高度和宽度设置为100%
答案 1 :(得分:0)
在计算容器的高度时,浏览器不会考虑绝对定位的侧边栏。因此,当没有主要内容或主要内容的高度不足以作为侧边栏时,容器太短。
要解决此问题,您可以使用jQuery将容器元素的最小高度设置为等于侧边栏的高度,例如:
$(document).ready(function(){
$(".wrap").css("min-height", function(){
return $(".sidebar").innerHeight()+30;
});});
如果您的侧边栏包含图片,我建议您使用imagesLoaded,以便脚本考虑图像的高度,而不是在加载时将它们设为0。 我们将边栏的计算高度加30,以计算上边距。