diff --git a/index.html b/index.html new file mode 100644 index 0000000..b3da7e1 --- /dev/null +++ b/index.html @@ -0,0 +1,114 @@ + + + + + + + + Blog Website + + + + +
+

THENEWSHIVE

+
+ + +
+
+ +
+ +
+ +
+ + +
+
+
+

Latest

+
+
+

Popular

+
+
+
+ +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..06485a6 --- /dev/null +++ b/script.js @@ -0,0 +1,76 @@ +const api = 'https://coding-week-2024-api.onrender.com/api/data'; + fetch_data(); + +async function fetch_data() { + const res = await fetch(api); + const data = await res.json(); + in_sidebar(data); + +} + +function in_sidebar(data){ + const new_news = document.getElementById('scroll_bar'); + const sec1 = document.getElementById('sec1'); + const sub_sec1 = document.getElementById('sub_sec1'); + data.forEach((news,index) => { + if(index>=4){ + const new_newsss = document.createElement('div'); + new_newsss.classList.add('box6'); + new_newsss.innerHTML = + ` + ${news.headline} + + ${news.date} + ` + new_newsss.addEventListener('click', ()=> pop_uppp(news)); + new_news.appendChild(new_newsss) + } + else if(index === 1 || index === 0 ) + { + const new_newsss = document.createElement('div'); + new_newsss.classList.add(`box${index+1}`); + new_newsss.style.backgroundImage = `url(${news.image})`; + new_newsss.innerHTML = + `
+ ${news.type} + Featured +
+

${news.headline}

+
${news.author} + ${news.date}
` + new_newsss.addEventListener('click', ()=> pop_uppp(news)); + + sec1.appendChild(new_newsss) + } + else + { + const new_newsss = document.createElement('div'); + new_newsss.classList.add(`box${index+1}`); + new_newsss.style.backgroundImage = `url(${news.image})`; + new_newsss.innerHTML = + `
+ ${news.type} + Featured +
+

${news.headline}

+
${news.author} + ${news.date}
` + new_newsss.addEventListener('click', ()=> pop_uppp(news)); + sub_sec1.appendChild(new_newsss) + } + } + +); +} +function pop_uppp(news) { + const popup = document.getElementById('popup'); + const to_add = document.getElementById('pop_up'); + to_add.innerHTML = ` + × +

${news.content}

+ `; + popup.style.display = 'block'; + document.getElementById('button').addEventListener('click', () => { + popup.style.display = 'none'; + }); +} \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..1da977a --- /dev/null +++ b/style.css @@ -0,0 +1,380 @@ +body{ + background-color: #f8f8f8; +} +h1{ + font-size: 4.0em; + background-color: black; + color: white; + margin: 0px; + margin-bottom: 0px; + padding: 0px; +} +.nav_bar ul{ + display: flex; + list-style: none; + background-color: rgb(248, 248, 248); + padding: 0px; + margin: 0px; + margin-left: 6px; + margin-top: 0px; + margin-bottom: 0px; + overflow: hidden; +} +.nav_bar a{ + color: black; + font-size: 1.35em; + text-decoration: none; + padding: 10px; + margin-left: 8px; + display: block; + text-align: center; +} +.nav_bar a.home{ + background-color: black; + color: white; +} +.nav_bar a.drop{ + background-color: rgb(248, 248, 248); +} +.nav_bar a:hover{ + color: white; + background-color: black; +} +.nav_bar li{ + float: left; +} +.nav_bar a.helo:hover { + background-color: rgb(248, 248, 248); + color: black; +} +.nav_bar a.drop:hover { + background-color: rgb(248, 248, 248); + color: black; +} +.icon{ + margin-left: auto; + margin-right: 10px; + background-color: rgb(248, 248, 248); +} +.nav_bar1 ul{ + display: flex; + list-style: none; + background-color: rgb(236, 236, 236); + padding: 0px; + margin: 0px; + overflow: hidden; +} +.nav_bar1 a{ + color: black; + text-decoration: none; + padding: 10px; + display: block; + text-align: center; +} +.icon2{ + margin-left: auto; + margin-top: 8px; + margin-right:0px; + padding: 0px; +} +.icon1{ + margin-left: 5px; + max-width: 20%; + margin-right: 0px; +} +.nav_bar1 .texts{ + color: rgb(97, 97, 97); + margin-left: 50px; +} + +.nav_bar1 .texts1{ + color: rgb(97, 97, 97); + margin-left: 0px; +} +.degree{ + margin-left: 0px; + margin-right: 0px; + padding: 0px; +} +.dropdown a{ + background-color:white; + display: block; + color: black; + padding: 10px; + margin-top: 0px; + margin-left: 0px; + cursor: pointer; +} +.dropdown .content{ + display: none; + position: absolute; + background-color:white; + min-height: 100px; + min-width: 170px; + box-shadow: 2px 2px 5px; +} +.dropdown:hover .content{ + display: block; +} +.container{ + display: inline-flex; +} +.container2{ + display: inline-flex; +} +.container4{ + display: inline-flex; +} +.box1{ + margin-top: 50px; + margin-left: 15px; + background-size: 100% 100%; + width: 440px; + height: 470px; + color: white; + float: left; + border-radius: 10px; +} +.scroll_barrr{ + width: 460px; + overflow-y: scroll; + max-height: 400px; + float: left; +} +.box2{ + margin-top: 50px; + margin-left: 10px; + background-size: 100% 100%; + width: 310px; + float: left; + height: 470px; + border-radius: 10px; +} +.ph1 +{ + float: left; + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; + width: 100px; + height: 70px; + border-radius: 10px; +} +.box3{ + margin-left: 15px; + margin-top: 50px; + background-size: 100% 100%; + width: 240px; + border-radius: 10px; + height: 226px; + float: left; +} +.box4{ + margin-left: 15px; + margin-top: 16px; + background-size: 100% 100%; + width: 240px; + height: 226px; + border-radius: 10px; + float: left; + +} +.box5{ + margin-top: 50px; + margin-left: 35px; + background-color: black; + width: 200px; + color: white; + height: 70px; + text-align: center; + border-top-left-radius:10px ; + border-bottom-left-radius: 10px; + font-size: 1.6em; +} + +.box7{ + background-color: white; + width: 200px; + height: 70px; + border-top-right-radius:10px ; + border-bottom-right-radius: 10px; + text-align: center; + font-size: 1.6em; + margin-top: 50px; +} + +.box6{ + margin-left: 35px; + margin-top: 10px; + background-color: white; + width: 400px; + height: 90px; + border-radius: 10px; + display: flow-root; +} +a.boxtext{ + font-size: 1.1em; + color: black; + text-decoration: none; + margin-top: 14px; + margin-left: 14px; + margin-bottom: 10px; + display: flow-root; +} +.box7 h3{ + margin-bottom: 10px; + color: rgb(147, 147, 147); + transform: translate(0,-45%); +} +.box5 h3{ + margin-bottom: 10px; + color: white; + transform: translate(0,-45%); +} +.box1 h4{ + margin-top: 0px; + font-size: 2em; + margin-bottom: 5px; + color: white; + margin-left: 15px; +} +.box1 h6{ + border: 10px; + font-size: 1.2em; + margin-top: 290px; + margin-bottom: 0px; + color: black; +} +.box1 span +{ + border: 1px solid; + border-color: #fff; + margin-left: 15px; + background-color: #000; + border-radius: 50px; + color: #fff; + font-size: 1.1rem; + font-weight: 50; + +} +.box1 h5{ + font-size: 1.2em; + margin-top: 0px; + margin-top: 0px; + color: white; + margin-left: 10px; +} +.box2 h4{ + margin-top: 5px; + color: white; + font-size: 1.5em; + margin-bottom: 5px; + margin-left: 15px; +} +.box2 h6{ + border: 10px; + font-size: 1.2em; + color: black; + margin-top: 325px; + margin-bottom: 0px; +} +.box2 span +{ + border: 2px solid; + border-color: white; + margin-left: 15px; + background-color: #000; + border-radius: 50px; + color: #fff; + font-size: 1.1rem; + font-weight: 50; +} +.box2 h5{ + font-size: 1.2em; + margin-top: 0px; + margin-top: 0px; + margin-left: 10px; + color: white; +} +.box3 h5{ + font-size: 1.2em; + margin-top: 0px; + margin-top: 0px; + margin-left: 10px; + color: white; +} +.box3 h4{ + margin-top: 5px; + color: white; + font-size: 1em; + margin-bottom: 5px; + margin-left: 10px; +} +.box3 h6{ + border: 10px; + font-size: 1em; + color: black; + margin-top: 125px; + margin-bottom: 0px; +} +.box3 span +{ + border: 2px solid; + border-color: white; + margin-left: 15px; + background-color: #000; + border-radius: 50px; + color: #fff; + font-size: 1.1rem; + font-weight: 50; +} +.box4 h4{ + margin-top: 5px; + color: black; + font-size: 1em; + margin-bottom: 5px; + margin-left: 10px; +} +.box4 h6{ + border: 10px; + font-size: 1em; + color: black; + margin-top: 125px; + margin-bottom: 0px; +} +.box4 h5{ + font-size: 1em; + margin-top: 0px; + margin-top: 0px; + margin-left: 10px; + color: black; +} +.box4 span +{ + border: 2px solid; + border-color: white; + margin-left: 15px; + background-color: black; + border-radius: 50px; + color: white; + font-size: 1.1rem; + font-weight: 50; +} + +.to_open { + display: none; + position: fixed; + left: 40%; + top: 40%; + width: 400px; + height: 300px; + overflow: auto; +} +.popupp { + background-color: white; + padding: 20px; +} +.to_close{ + float: right; + font-size: 25px; +} \ No newline at end of file