I'm trying to create a small Notepad application online using just CSS and HTML. For some reason, my application creates a weird glitch where you scroll down in the text area far enough and scroll back up to find the header is missing.
https://jsfiddle.net/2v7ptadh/
How can I fix this issue?
This is the CSS code that is creating the error. If you want to view the full code, click on the JS Fiddle link above.
html,
body {
display: block;
box-sizing: border-box;
padding: 0;
margin: 0;
background-color: #888;
height: 100%;
width: 100%;
overflow-y: hidden;
}
div#header {
display: block;
width: 100%;
height: 40px;
border-left: 2px solid rgb(100, 125, 130);
border-top: 2px solid rgb(150, 175, 140);
border-bottom: 2px solid rgb(60, 48, 75);
border-right: 2px solid rgb(80, 84, 90);
background: #bbb;
box-sizing: border-box;
line-height: 40px;
text-align: center;
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
font-weight: 900;
z-index: 4
}
div#app {
z-index: 2;
display: block;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0;
margin: 0;
}
textarea#app-input {
display: block;
box-sizing: border-box;
padding: 4px;
margin: 0;
border: none;
outline: none;
width: 100%;
height: 100%;
line-height: 23px;
font-size: 20px;
resize: none;
}
textarea::selection {
background: #000;
color: #fff;
}
Video of issue: http://recordit.co/2AxYmb9XxV
If you're going to set html/body to height: 100%; overflow-y: hidden; then #app shouldn't be height: 100% - change that to height: calc(100% - 40px) where 40px is the header height. That will keep everything in the viewport.
#import url('https://fonts.googleapis.com/css?family=Open+Sans');
html,
body {
display: block;
box-sizing: border-box;
padding: 0;
margin: 0;
background-color: #888;
height: 100%;
width: 100%;
overflow-y: hidden;
}
div#header {
display: block;
width: 100%;
height: 40px;
border-left: 2px solid rgb(100, 125, 130);
border-top: 2px solid rgb(150, 175, 140);
border-bottom: 2px solid rgb(60, 48, 75);
border-right: 2px solid rgb(80, 84, 90);
background: #bbb;
box-sizing: border-box;
line-height: 40px;
text-align: center;
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
font-weight: 900;
z-index: 4
}
div#app {
z-index: 2;
display: block;
width: 100%;
height: calc(100% - 40px);
box-sizing: border-box;
padding: 0;
margin: 0;
}
textarea#app-input {
display: block;
box-sizing: border-box;
padding: 4px;
margin: 0;
border: none;
outline: none;
width: 100%;
height: 100%;
line-height: 23px;
font-size: 20px;
resize: none;
}
textarea::selection {
background: #000;
color: #fff;
}
<div id="header">ONLINE NOTEPAD</div>
<div id="app">
<textarea id="app-input"></textarea>
</div>
try removing overflow-y:hidden from html and body
html,
body {
display: block;
box-sizing: border-box;
padding: 0;
margin: 0;
background-color: #888;
height: 100%;
width: 100%;
}
Related
I am having an issue here where the text overlaps the Emoji button .
Basically I want the text to stop before reaching the emoji.
I tried this which surprisingly did not work for me http://jsfiddle.net/36bw0nmo/14/
Thank you
This is my fiddle https://jsfiddle.net/w0s4y5nk/14/
textarea#sendMessage {
height:50px;
width: calc(100vw - 15px);
position: absolute;
bottom: 16px;
resize: none;
border: none;
font-size: 13px;
padding: 5px 5px 5px 10px;
border: solid 5px
}
#myButton {
position: absolute;
bottom: 10px;
right: 5px;
margin-left: 60px;
}
<textarea id="sendMessage"> </textarea>
<p id="myButton" role="img" onclick='$("#picker").toggle()'>🙂</p>
<emoji-picker id="picker"> </emoji-picker>
I hope this is what you want
.textarea-container {
display: flex;
justify-content: space-between;
align-items: flex-end;
height: 50px;
max-width: 96%;
width: 96%;
margin: 0 auto;
position: absolute;
box-sizing: content-box;
bottom: 16px;
padding: 6px;
border: solid 1px #ccc;
border-radius: 4px;
}
textarea#sendMessage {
max-width: 100%;
width: 100%;
height: 100%;
resize: none;
border: none;
font-size: 13px;
scrollbar-width: none;
-ms-overflow-style: none;
}
textarea#sendMessage::-webkit-scrollbar {
display: none;
}
textarea:focus {
outline: none !important;
}
#myButton {
width: 24px;
height: 24px;
display: inline;
cursor: pointer;
padding-left: 4px;
margin: 0;
}
<div class="textarea-container">
<textarea id="sendMessage"> </textarea>
<p id="myButton" role="img" onclick='$("#picker").toggle()'>🙂</p>
<emoji-picker id="picker"> </emoji-picker>
</div>
run snippet code and see the result.
For some reason my h3 element wants to scroll. I've tried testing and it appears to be in this code.
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
overflow-x: hidden;
}
html,
body {
height: 100%;
width: 100%;
}
.model-detail-caption {
font-family: "Oswald";
font-size: 5rem;
font-weight: 700;
color: #fff;
position: absolute;
bottom: 20%;
left: 20px;
width: 100%;
border-left: 4px solid var(--accent);
padding: 0px 0px 0px 10px;
}
<h3 class="model-detail-caption">Some Text</h3>
position: absolute; bottom: 20%; left: 20px; will cause this behaviour.
My header is devided in 3 sections: left, center and right. The left section is empty. In the center section I have my page title and in the right section I placed an "Account" link with an icon next to it. The link contains the word ACCOUNT and an icon. the icon is somehow pushed to the top and leaves a blank space below it next to the word. I want them both in one line and on the same hight. How can I achieve this? I added a red background to make the problem better understandable.
html {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
overflow: inherit;
}
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
position: relative;
height: 100%;
}
#in {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100%;
}
/* ------------------------------------------------------------------------ */
/* -------------------------------- HEADER -------------------------------- */
/* ------------------------------------------------------------------------ */
header {
background-color: #131b23;
border-bottom: 6px solid #0f151a;
text-align: center;
left: 0;
top: 0;
width: 100%;
height: 170px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
z-index: 99;
}
#left {
background-color: green;
width: 20%;
position: absolute;
height: 164px;
}
#center {
background-color: red;
width: 60%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: absolute;
left: 20%;
right: 20%;
height: 164px;
}
#right {
background-color: blue;
width: 20%;
height: 100%;
position: absolute;
right: 0;
height: 164px;
}
#heading {
font-size: 60px;
display: block;
margin-bottom: -7px;
margin-top: 15px;
}
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: red;
position: absolute;
right: 30px;
top: 15px;
}
.navigationicon {
position: relative;
width: 24px;
margin: 0;
padding: 0;
top: 50%;
bottom: 50%;
}
<header>
<div id="left">
</div>
<div id="center">
<h1 id="heading">My Page</h1>
</div>
<div id="right">
<a class="accountlink" href="login.html">Account <img class="navigationicon" src="https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png"></a>
</div>
</header>
Can you check this ?
html {
height: 100%;
box-sizing: border-box;
overflow: hidden;
}
*,
*:before,
*:after {
box-sizing: inherit;
overflow: inherit;
}
body {
background-color: #f5f5f5;
margin: 0;
padding: 0;
position: relative;
height: 100%;
}
#in {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100%;
}
/* ------------------------------------------------------------------------ */
/* -------------------------------- HEADER -------------------------------- */
/* ------------------------------------------------------------------------ */
header {
background-color: #131b23;
border-bottom: 6px solid #0f151a;
text-align: center;
left: 0;
top: 0;
width: 100%;
height: 170px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
z-index: 99;
}
#left {
background-color: green;
width: 20%;
position: absolute;
height: 164px;
}
#center {
background-color: red;
width: 60%;
margin-left: auto;
margin-right: auto;
height: 100%;
position: absolute;
left: 20%;
right: 25%;
height: 164px;
}
#right {
background-color: blue;
width: 20%;
height: 100%;
position: absolute;
right: 0;
height: 164px;
}
#heading {
font-size: 60px;
display: block;
margin-bottom: -7px;
margin-top: 15px;
}
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: white;
position: absolute;
left: 50px;
top: 20px;
background: url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png");
background-size: 24px;
background-repeat: no-repeat;
background-position-x: right;
background-position-y: 0px;
width: 40%;
line-height: 2;
}
<header>
<div id="left">
</div>
<div id="center">
<h1 id="heading">My Page</h1>
</div>
<div id="right">
<a class="accountlink" href="login.html">Account </a>
</div>
</header>
Four changes to your css code to get there: 2 at .navigationicon and 2 at .accountlink
.accountlink {
font-family: "Helvetica";
text-decoration: none;
font-weight: 800;
color: #ffffff;
font-size: 13px;
letter-spacing: 1px;
text-transform: uppercase;
background-color: red;
position: absolute;
right: 80px;
top: 70px;
}
.navigationicon {
position: relative;
width: 12px;
margin: 0 0 2px -5px;
padding: 0;
top: 50%;
bottom: 50%;
}
I have this image and I need to reply it.
I already did most of the code, however I'm having some trouble doing the black box.
It needs to be:
- on top of "redbox"
- behind the "bluebox"
- on top of "blueinbox"
body {
padding-top: 0 !important;
padding-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
margin:0 !important;
width: 100% !important;
-webkit-text-size-adjust: 100% !important;
-ms-text-size-adjust: 100% !important;
-webkit-font-smoothing: antialiased !important;
}
.container {
background-color: #e1e1e1;
height: 200px;
width: 400px;
border: 0;
margin: auto;
display: table;
margin-top: 20px;
position: relative;
}
.redbox {
background-color: #fff;
height: 120px;
width: 120px;
margin: 20px 20px 0 0;
display: table;
right: 0;
border-style: solid;
border-width: 1px;
border-color: red;
border-radius: 5px;
position: absolute;
}
.bluebox {
background-color: #fff;
height: 120px;
width: 120px;
margin: 60px 60px 0 0;
display: table;
right: 0;
border-style: solid;
border-width: 1px;
border-color: blue;
position: absolute;
border-left-style: dashed;
}
.blueinbox {
background-color: #00aeef;
height: 80px;
width: 80px;
margin: 20px 20px 0 0;
float: right;
}
.ninja {
color: #fff;
font-family: "Open Sans", Arial, sans-serif;
letter-spacing: 2px;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}
<body>
<div class="container">
<div class="redbox">
</div>
<div class="bluebox">
<div class="blueinbox">
<div class="ninja">
<p>NINJA!</p>
</div>
</div>
</div>
</div>
</body>
Done.
body {
font: 500 16px 'Open Sans', Arial, sans-serif;
color: #fff;
}
.container {
position: relative;
max-width: 400px;
height: 200px;
margin: 2rem auto;
border: 1px solid #000;
background-color: #eee;
}
.box-red, .box-blue-light, .box-blue-dark, .box-black {
position: absolute;
}
.box-red {
top: 20px;
right: 20px;
width: 120px;
height: 120px;
border: 1px solid red;
border-radius: 5px;
}
.box-black {
top: 40px;
right: 40px;
width: 60px;
height: 60px;
background-color: #000;
}
.box-blue-light {
top: 80px;
right: 80px;
width: 80px;
height: 80px;
background-color: #05adeb;
}
.box-blue-light::before {
content: "";
position: absolute;
right: 0;
width: 20px;
height: 20px;
background-color: #000;
}
.box-blue-light h5 {
margin-top: 2rem;
font: 500 1rem 'Open Sans';
letter-spacing: 2px;
text-align: center;
}
.box-blue-dark {
top: 60px;
right: 60px;
width: 120px;
height: 120px;
border: 1px solid blue;
border-left-style: dashed;
background: #fff url("https://media1.giphy.com/media/fLg3MEWdgH5Ti/200.gif");
}
.box-blue-dark::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(170,50,90,.25)
}
<body>
<div class="container">
<div class="box-red"></div>
<div class="box-black"></div>
<div class="box-blue-dark"></div>
<div class="box-blue-light"><h5>NINJA!<h5></div>
</div>
</body>
Add z-index:1; to .bluebox.
body {
padding-top: 0 !important;
padding-bottom: 0 !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
margin:0 !important;
width: 100% !important;
-webkit-text-size-adjust: 100% !important;
-ms-text-size-adjust: 100% !important;
-webkit-font-smoothing: antialiased !important;
}
.container {
background-color: #e1e1e1;
height: 200px;
width: 400px;
border: 0;
margin: auto;
display: table;
margin-top: 20px;
position: relative;
}
.redbox {
background-color: #fff;
height: 120px;
width: 120px;
margin: 20px 20px 0 0;
display: table;
right: 0;
border-style: solid;
border-width: 1px;
border-color: red;
border-radius: 5px;
position: absolute;
}
.bluebox {
background-color: #fff;
height: 120px;
width: 120px;
margin: 60px 60px 0 0;
display: table;
right: 0;
border-style: solid;
border-width: 1px;
border-color: blue;
position: absolute;
border-left-style: dashed;
}
.blueinbox {
background-color: #00aeef;
height: 80px;
width: 80px;
margin: 20px 20px 0 0;
float: right;
}
.blackbox {
background-color: #000;
height: 80px;
width: 80px;
margin: 20px 20px 0 0;
float: right;
}
.ninja {
color: #fff;
font-family: "Open Sans", Arial, sans-serif;
letter-spacing: 2px;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}
<body>
<div class="container">
<div class="redbox">
<div class="blackbox"></div>
</div>
<div class="bluebox">
<div class="blueinbox">
<div class="ninja">
<p>NINJA!</p>
</div>
</div>
</div>
</div>
</body>
I am new to the world of webdesign and am not completely not entirely sure how to create a full background image.
I am playing around with the warship.ts example on typescriptlang.org, and I am trying to add in a background photo of a battleship. Below is the code of the CSS file:
html
{
width: 100%;
height: 100%;
-ms-content-zooming: none;
margin: 0px;
border: 0px;
padding: 0px;
background-image: url(pictures/cats.jpg); //My code
background-size: cover;
}
body {
font-family: Verdana;
width: 100%;
height: 100%;
/*background-color: #b5caae;*/
background: url('img/bg2.jpg');
margin: 0px;
border: 0px;
padding: 0px;
min-height: 480px;
min-width: 640px;
}
#header {
width: 100%;
height: 25%;
}
#boards {
width: 100%;
height: 75%;
}
.quadrant
{
display: inline-block;
box-sizing: border-box;
-moz-box-sizing: border-box;
width: 40%;
margin: 2%;
vertical-align: top;
}
#banner {
font-size: 40pt;
font-weight: 800;
font-style: italic;
color: white;
text-shadow: -1px 0 black, 0 2px black, 1px 0 black, 0 -1px black;
height: 100px;
}
#status
{
width: 80%;
border: 1px dotted gray;
padding: 1%;
background-color: #CCCCCC;
height: 80%;
}
.board {
background-color: #111111;
border: 2px groove black;
height: 80%;
padding: 0%;
position: relative;
}
.cell {
box-sizing: border-box;
-moz-box-sizing: border-box;
float: left;
height: 10%;
width: 10%;
border: 1px dotted #A0A0FF;
margin: 0px;
padding: 0px;
position: relative;
}
.notBombed {
opacity: 0.2;
background: url('img/bg.jpg') repeat;
/*background-color: black;*/
z-index: 0;
}
.cellHit {
opacity: 0.5;
background-color: #C00000;
z-index: 2;
}
.cellMiss{
opacity: 0.5;
background-color: #008000;
z-index: 2;
}
.ship {
position: absolute;
box-sizing: border-box;
-moz-box-sizing: border-box;
margin: 0%;
padding: 0%;
width: 10%;
height: 10%;
border-radius: 20%;
/*background-color: #FFFF80;*/
background: #666666;
border: 2px solid black;
z-index: 1;
-ms-touch-action: none;
}
.dropTarget {
background-color: white;
}
As an IDE, I am using Visual Studio 2015. From the examples I have seen online, I place the url image in the solution explorer, then I reference it in the html method, and then set the image as a color. However, whenever I try to run it, nothing changes. Is there something that I am missing from the code, or am I updating this in the wrong spot? Do I need to change the HTML/ts code?
If you are trying to html background image in every resolution, try with this code
background: url(pictures/cats.jpg) no-repeat fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
do this for only body{} sector. remove background images code from other sectors.