-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Refactor CSS to improve readability and maintainability
- Loading branch information
1 parent
f990a06
commit 6db43fa
Showing
3 changed files
with
129 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
background-color: #1f1f1f; | ||
} | ||
body{ | ||
overflow:hidden; | ||
} | ||
.container { | ||
background-color: #fff; | ||
border: 1px solid #ababab; | ||
height: 500px; | ||
width: 500px; | ||
margin: 0; | ||
padding: 0 20px; | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: center; | ||
overflow: hidden; | ||
margin: 20px 0; | ||
-webkit-user-select: none; | ||
-webkit-user-drag: none; | ||
-webkit-app-region: no-drag; | ||
cursor: default; | ||
} | ||
|
||
.text { | ||
background-color: #fff; | ||
text-align: justify; | ||
text-justify: inter-word; | ||
font-size: 60px; | ||
filter: blur(2px); | ||
font-family: Arial; | ||
font-stretch: ultra-condensed; | ||
margin: 20px; | ||
} | ||
h1 { | ||
color: #ece8e8; | ||
text-align: justify; | ||
text-justify: inter-word; | ||
font-size: 60px; | ||
font-family: Arial; | ||
font-stretch: ultra-condensed; | ||
margin: 0; | ||
} | ||
h3{ | ||
color:#696969; | ||
font-size:12px; | ||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | ||
padding-bottom: 20px; | ||
} | ||
input { | ||
color: #ece8e8; | ||
background-color: #2e2e2e; | ||
border: 0; | ||
outline: none; | ||
height: 30px; | ||
width: 500px; | ||
} | ||
.center { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
.social-networks { | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 20px; | ||
} | ||
.social-networks i { | ||
font-size: 40px; | ||
color: #ece8e8; | ||
margin: 0 10px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function adjustTextSize() { | ||
const container = document.getElementById("container"); | ||
const text = document.getElementById("text"); | ||
|
||
text.style.fontSize = "50px"; | ||
text.style.lineHeight = "normal"; | ||
|
||
const textClone = text.cloneNode(true); | ||
textClone.style.visibility = "hidden"; | ||
textClone.style.position = "absolute"; | ||
textClone.style.lineHeight = "normal"; | ||
textClone.style.width = container.clientWidth + "px"; | ||
container.appendChild(textClone); | ||
|
||
let fontSize = parseInt(window.getComputedStyle(text).fontSize, 10); | ||
const containerHeight = container.clientHeight; | ||
const containerWidth = container.clientWidth; | ||
let textHeight, textWidth; | ||
|
||
do { | ||
textHeight = textClone.scrollHeight; | ||
textWidth = textClone.scrollWidth; | ||
|
||
if (textHeight > containerHeight || textWidth > containerWidth) { | ||
fontSize -= 1; | ||
textClone.style.fontSize = fontSize + "px"; | ||
} else { | ||
break; | ||
} | ||
} while (fontSize > 0); | ||
|
||
text.style.fontSize = fontSize + "px"; | ||
textClone.style.fontSize = fontSize + "px"; | ||
textHeight = textClone.scrollHeight; | ||
const newLineHeight = containerHeight / (textHeight / fontSize); | ||
text.style.lineHeight = (newLineHeight > fontSize ? newLineHeight : fontSize) + "px"; | ||
container.removeChild(textClone); | ||
} | ||
|
||
function updateText() { | ||
const textInput = document.getElementById("textInput"); | ||
const text = document.getElementById("text"); | ||
|
||
text.textContent = textInput.value; | ||
adjustTextSize(); | ||
} | ||
|
||
window.onload = adjustTextSize; | ||
window.onresize = adjustTextSize; |