ShiggyDooDah
ShiggyDooDah

Reputation: 497

css border around my web page

I am currently having a few problems positioning a border around my website. i am currently hosting the website here. I want a yellow border to go around the body but about 20-30px from the edges. i also want the border to be responsive so when i resize the browser the border follows too. Everything i've tried just wont work, anyone know what i need to do for it to work?

html{
  height: 100%;
  width: 100%;
  overflow: hidden;
  overflow-x: hidden;
  overflow-y: hidden;
}

body{
  margin: 0px; 
  color: #ffff00; 
  font-family: 'PT Sans', sans-serif;
  text-align: center;
  background-color: black;

}

p a {
  color: #ffff00;
  text-decoration: none;
  letter-spacing: 5px;
}

a:hover{
  color: #ffff00;
  text-decoration: none;
}

video{
  position: fixed;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
}

img{
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin: auto auto;
}

.screen {
  position: fixed;
  display: block;
  right: 0;
  bottom: 0;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  background: black;
  opacity: 0.3;

}


/* Index Page*/ 

.container{
  min-width: 100%;
  min-height: 100%;
  margin: 0px auto; 
  position: fixed;

}


.logo{
  padding-top: 100px;
  padding-bottom: 40px;
  margin: 0px auto; 
  width: 60%;
}

.logo h1{
  font-size: 30px;
  letter-spacing: 4px;
}

.nav{
  padding-top: 50px;
  margin: 0px auto; 
  width: 60%;
  font-size: 25px;
}

.nav-menu{
  margin: 20px auto;
  font-size: 25px;
  display: inline-block;
  transform:scale(1,1.4); /* W3C */
  -webkit-transform:scale(1,1.4); /* Safari and Chrome */
  -moz-transform:scale(1,1.4); /* Firefox */
  -ms-transform:scale(1,1.4); /* IE 9 */
  -o-transform:scale(1,1.4); /* Opera */
  padding: 13px 2px 1px 2px;
  border: 3px solid #ffff00;
  line-height: 0px;
  text-transform:

}

.nav-menu a:hover{
  color: white; 
  border: 4px solid #0000;
}

Upvotes: 4

Views: 6452

Answers (3)

fnune
fnune

Reputation: 5494

Here's a (though pretty hacky) working solution: https://jsfiddle.net/2shj75f7/

I used body {height:100%;} (not only on html) and a ghost element <div class="bottom-border"></div> styled as follows:

.bottom-border {
  bottom:0;
  position:fixed;
  height:30px;
  width:100%;
  background:yellow;
  z-index:999;
}

I hope this is what you needed.


Update

New solution to suit what you asked for in the comment: https://jsfiddle.net/2shj75f7/1/

I used height:calc(100% - 60px); to get the desired result on the border:

body{
    height:calc(100% - 60px);
    color: #ffff00; 
    font-family: 'PT Sans', sans-serif;
    text-align: center;
    background-color: black;
    margin:30px;
    border:1px solid yellow;
}

Upvotes: 0

serraosays
serraosays

Reputation: 7849

Add this to your .screen class:

border: 25px solid yellow;

That's all you need because this is the class controlling the width and height of the page. Attaching a border to it will make it responsive, since it is acting a container for the entire site.

Upvotes: 0

Paulie_D
Paulie_D

Reputation: 114991

A pseudo-element could do that:

body {
  height: 100vh;
  margin: 0;
  padding: 0;
  position: relative;
}
body::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 10px solid yellow;
}

Upvotes: 3

Related Questions