Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To Do List #247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions todoslist project/todoslist project/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

<!DOCTYPE HTML>
<html>

<head>
<title>To-Do's List</title>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>

<body>
<div class="container">
<h1>To-do list</h1>

<div class="add-elements">
<input id="add" type="text" placeholder="add an element">
<button id="btn">Add</button>
</div>

<div class="element-list">
<ul id="list">
<li>add some work</li>
<li>add some work</li>
</ul>
</div>

</div>

<script src="script.js"></script>
</body>

</html>
26 changes: 26 additions & 0 deletions todoslist project/todoslist project/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

const input = document.querySelector("#add");
const btn = document.querySelector("#btn");
const list = document.querySelector("#list");
var el = document.getElementsByTagName('li');

btn.onclick = function(){

var txt = input.value;
if(txt ==''){
alert('you must write something');
}else{
li = document.createElement('li');
li.innerHTML = txt;
list.insertBefore(li,list.childNodes[0]);
input.value = '';
}

};


list.onclick = function(ev){
if(ev.target.tagName == 'LI'){
ev.target.classList.toggle('checked');
}
};
75 changes: 75 additions & 0 deletions todoslist project/todoslist project/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

@import url('https://fonts.googleapis.com/css?family=Nunito&display=swap');
*{
margin: 0;
padding: 0;
outline: 0;
}
body
{
background: #f6d365
}

.container
{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
background-color: #fafafa;
box-shadow: 0 2px 8px rgba(0,0,0,.16);
width: 460px;
height: 680px;
text-align: center;
font-family: 'Nunito',sans-serif;

}
h1
{
margin: 12px 0;
}
.add-elements{
margin: 12px 0;

}
input{
padding: 6px 4px;
width: 70%;
}
button{
padding: 7px 14px;
background-color: #00b0ff;
border: none;
border-radius: 4px;
color: #fafafa;

}
.element-list{
height: 550px;
overflow-y: scroll
}
ul{
padding: 15px;

}
li{
list-style: none;
padding: 10px 5px;
background-color: #fff;
margin: 12px 0;
box-shadow: 0 2px 8px rgba(0,0,0,.16);
border-radius: 3px;
transition: .4s;
}
button:hover{
background-color: #1565c0;
}

li:hover{
background-color: #e0e0e0;
}

.checked{
text-decoration: line-through;
background-color: #e0e0e0;
}