简体   繁体   English

删除空白和更漂亮的CSS

[英]Removing the white space & prettier css

I've made my own static website from scratch using html5 and css(3) only.But I have got 2 issues. 我仅使用html5和css(3)从头开始创建了自己的静态网站。但是我遇到了2个问题。

The first one is the white space between the top's menu and header's image bottom.I've tried everything. 第一个是顶部菜单和标题图像底部之间的空白。我已经尝试了所有方法。

Maybe the only solution for that is float:left; 也许唯一的解决方案是float:left; but then the image goes into the navigation tag or negative value on margin's property but I've heard that this technique is bad. 但随后图像进入了导航标签或margin属性的负值,但我听说这种技术不好。

The second issue I'll display via image http://www.filedropper.com/discoversite that's my simple WebSite. 我将通过图像http://www.filedropper.com/discoversite显示第二个问题 ,这是我的简单WebSite。 I know my css is awful but I'm still a beginner. 我知道我的CSS很糟糕,但我仍然是初学者。 The second issue is here. 第二个问题在这里。 http://postimg.org/image/5adp6379d/ . http://postimg.org/image/5adp6379d/ As you can see the text is going out of the box. 如您所见,文本已开箱即用。 (I am using % in css for more responsive). (我在CSS中使用%来提高响应速度)。 I will be glad if anyone can help me. 如果有人可以帮助我,我将非常高兴。

  1. I can only have a guess for your first issue as I don't know the exact code for your website (create jsfiddle :D ). 我只能猜测第一个问题,因为我不知道您网站的确切代码(创建jsfiddle:D)。 Try to apply vertical-align: bottom; 尝试应用vertical-align: bottom; or display: block; display: block; to your header image. 到标题图片。 Why? 为什么? Because images are placed like text and some letters like g , j , q and p are going underneath the bottom level. 因为图像的位置像文本一样,并且某些字母(例如gjqp)位于最下面。 Your browser will leave a tiny space for these letters. 您的浏览器将为这些字母留出很小的空间。 Also setting a min-width is a good solution like Kirk Logan said. 像Kirk Logan所说的那样,设置min-width也是一个很好的解决方案。
  2. And for your second problem there are multiple solutions (depending on what you want): 对于第二个问题,有多种解决方案(取决于您想要的):

    • You can handle your content with overflow: hidden; 您可以通过以下方式处理内容overflow: hidden; or overflow: scroll as Kirk Logan suggested. overflow: scroll按照Kirk Logan的建议overflow: scroll But this wouldn't make any sense in the case you have shown us in the picture. 但这对您在图片中向我们展示的情况没有任何意义。
    • Or (is a little more complex) you could remove the white borders on the left and right side (just when the screen is too small) in order to gain more space for the text. 或者(稍微复杂一点),您可以删除左侧和右侧的白色边框(仅当屏幕太小时),以获取更多的文本空间。 This can be done by: 这可以通过以下方式完成:

       @media only screen and (max-width: 768px) { #BigBorder1 { border-width: 0px; } #BigBorder2 { border-width: 0px; } } 

Everthing inside the outer brackets will only be applied when the screen's width is smaller than 768px. 仅当屏幕宽度小于768像素时,才会应用外部括号内的所有内容。 But to be honest this is usually done the other way round: When the screen is bigger than 768px then something happens. 但老实说,这通常是相反的:当屏幕大于768px时,就会发生某些事情。 This simplification is only in order to make it easier for you. 这种简化只是为了使您更轻松。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM