I want to create this homepage for my site which only accepts add-ons of html/css without retouching any other rule.
Only achieved making the blocks themselves but no clue on how to put images behind the buttons,center everything up and make it responsive...
Any tip?
Homepage intended
page link: www.lluisballbe.smugmug.com
Code used already is here:
html,
body {
height: 100%;
width: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
h1 {
margin: 0;
}
a {
display: inline-block;
}
#business-top {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
background:turquoise;
}
#business-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
#logo-separator {
text-align: center;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
flex: 0;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin: auto;
max-width: 150px;
display: inline-block;
overflow: hidden;
margin: -75px;
position: absolute;
z-index:1;
}
#photography-bottom {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
background:gray;
}
#photography-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
h1 {
color: #ff7600;
text-align: center;
font-size: 1.4em;
vertical-align: middle;
line-height: 2.2em
}
#business-top,
#photography-bottom {
pointer-events: none;
position: relative;
transition: 1s;
min-height: 200px;
}
#business-top a,
#photography-bottom a {
pointer-events: auto;
}
#business-top:hover,
#photography-bottom:hover {
flex: 3;
}
#business-top a:hover:before,
#photography-bottom a:hover:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<div id="business-top">
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"> </div>
</div>
<div id="photography-bottom">
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
Images to be used (each should cover 50%, can resize them and change pixel size if needed):
https://dl.dropboxusercontent.com/u/54898895/Public.rar
[Top Image][3]
[Bottom image][4]
I'd do it this way:
Add height: 50vh; to #business-top and #photography-bottom for both outter container.
Give your containers your custom background-images: background-image: url('url to image');
Make sure the images have background-size: cover;
Add your #logo-separator with position:absolute;
and top: calc( 50% - (height_of_sperator)px;
Related
The purple Navbar at the top of the page pushes the container "container2" off screen. Is there any possible way I can make it so the "container2" div does not overflow with the proper padding of 5px at the bottom?
#import url('https://fonts.googleapis.com/css2?family=Gugi&display=swap');
/*QuickReset*/ * { box-sizing: border-box; margin: 0; }
html {
height: 100%;
width: 100%
}
body {
background: black;
height: 100%;
position: relative;
overflow: hidden;
}
.navbar {
background: purple;
padding: 1em;
width: 100%;
position: relative;
top: 0;
}
.navbar .logo {
text-decoration: none;
font-family: 'Gugi', cursive;
font-weight: bold;
font-size: 1.5em;
color: white;
}
.navbar .container {
display: grid;
grid-template-columns: 100px auto;
justify-content: unset;
}
.navbar nav {
display: flex;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.container2 {
display: flex;
width: 100%;
height: 100%;
position: relative;
gap: 5px;
padding: 5px;
}
.one,
.two {
border: 3px solid green;
border-radius: 5px;
}
.one { width: 10%; background: red; }
.two { width: 90%; background: blue; }
<div class="navbar">
<div class="container">
<a class="logo" href="#">Logo</a>
</div>
</div>
<div class="container2">
<div class="one">
</div>
<div class="two">
</div>
</div>
Resulting Page
I am new to HTML and CSS so any helps greatly appreciated.
Stack overflow wants more content besides code but im not too sure what else to add.
Remove overflow: hidden from body:
#import url('https://fonts.googleapis.com/css2?family=Gugi&display=swap');
/*QuickReset*/
* {
box-sizing: border-box;
margin: 0;
}
html {
height: 100%;
width: 100%
}
body {
background: black;
height: 100%;
position: relative;
/*overflow: hidden;*/
}
.navbar {
background: purple;
padding: 1em;
width: 100%;
position: relative;
top: 0;
}
.navbar .logo {
text-decoration: none;
font-family: 'Gugi', cursive;
font-weight: bold;
font-size: 1.5em;
color: white;
}
.navbar .container {
display: grid;
grid-template-columns: 100px auto;
justify-content: unset;
}
.navbar nav {
display: flex;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.container2 {
display: flex;
width: 100%;
height: 100%;
position: relative;
gap: 5px;
padding: 5px;
}
.one,
.two {
border: 3px solid green;
border-radius: 5px;
}
.one {
width: 10%;
background: red;
}
.two {
width: 90%;
background: blue;
}
<div class="navbar">
<div class="container">
<a class="logo" href="#">Logo</a>
</div>
</div>
<div class="container2">
<div class="one">
</div>
<div class="two">
</div>
</div>
#import url('https://fonts.googleapis.com/css2?family=Gugi&display=swap');
/*QuickReset*/ * { box-sizing: border-box; margin: 0; }
body {
background: black;
height: 100vh;
position: relative;
overflow: hidden;
}
.navbar {
background: purple;
padding: 1em;
width: 100%;
position: relative;
top: 0;
height: 20%;
}
.navbar .logo {
text-decoration: none;
font-family: 'Gugi', cursive;
font-weight: bold;
font-size: 1.5em;
color: white;
}
.navbar .container {
display: grid;
grid-template-columns: 100px auto;
justify-content: unset;
}
.navbar nav {
display: flex;
justify-content: space-between;
background: none;
position: unset;
height: auto;
width: 100%;
padding: 0;
}
.container2 {
display: flex;
width: 100%;
height: 80%;
position: relative;
gap: 5px;
padding: 5px;
}
.one,
.two {
border: 3px solid green;
border-radius: 5px;
}
.one { width: 10%; background: red; }
.two { width: 90%; background: blue; }
<div class="navbar">
<div class="container">
<a class="logo" href="#">Logo</a>
</div>
</div>
<div class="container2">
<div class="one">
</div>
<div class="two">
</div>
</div>
you should divide the height of navbar and container 2
For the last couple of days I am working in a simple step by step tutorial layout (html/css), and I cannot make it responsive and limited to screen size at same time.
Here is what I have so far and what I am trying to do:
HTML:
<div id="tutorial">
<h1>Step 2 - Title</h1>
<h3>Second step description / instructions</h3>
<div id="content">
<div id="ctrls">
<img src="images/prev.png">
<img src="images/stop.png">
<img src="images/next.png">
</div>
<div id="image">
<img src="images/step2.jpg">
</div>
</div>
<div id="controls">
<div class="btn prev">
<img src="images/btn_prev.png">
<div class="btn next">
<img src="images/btn_next.png">
</div>
</div>
</div>
CSS:
* {
margin: 0;
padding: 0;
}
html, body {
overflow: hidden;
font-family: Arial;
}
#tutorial {
width: 100%;
height: 100vh;
background-color: #FFFFCC;
}
h1 {
padding: 20px;
font-size: 26px;
font-weight: bold;
text-align: center;
}
h3 {
font-size: 20px;
text-align: center;
font-weight: normal;
}
#content {
display: table;
margin: 0 auto;
padding: 16px;
height: calc(100vh - 220px);
background-color: #E6E6E6;
}
#content #image {
position: relative;
}
#content #image img {
width: 100%;
height: 100%;
max-height: 100%;
}
#content #ctrls {
position: absolute;
z-index: 99;
display: table;
padding: 2px;
}
#content #ctrls img {
width: 48px;
height: auto;
float: left;
}
#controls {
display: table;
margin: 4px auto;
}
#controls .btn {
margin-top: 6px;
float: left;
}
#controls .prev {
margin-right: 10px;
}
#controls .next {
margin-left: 10px;
}
#controls .off {
opacity: 0.4;
filter: alpha(opacity=40);
}
#controls .btn img {
border: 0;
}
Thank you for any help!
Try this variant. I rewrote your code a bit...
https://codepen.io/opmasan/pen/jObdmdd
:root {
--header-height: 100px;
--footer-height: 200px;
}
*{
margin: 0;
padding: 0;
}
html, body {
font-family: Arial;
}
#tutorial {
width: 100%;
height: 100vh;
background-color: #FFFFCC;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h1 {
padding: 20px;
font-size: 26px;
font-weight: bold;
text-align: center;
}
h3 {
font-size: 20px;
text-align: center;
font-weight: normal;
}
#content {
display: flex;
padding: 16px;
background-color: #E6E6E6;
}
#content #image {
position: relative;
}
#content #image img {
height: calc(100vh - var(--header-height) - var(--footer-height));
max-height:100%;
max-width: 100%;
object-fit: cover;
}
#content #ctrls {
position: absolute;
z-index: 99;
width: 100px;
height: 50px;
background-color: #3AE2CE;
}
#controls {
display: flex;
margin: 4px auto;
}
#controls .btn {
margin-top: 6px;
float: left;
}
#controls .prev {
margin-right: 10px;
}
#controls .next {
margin-left: 10px;
}
#controls .off {
opacity: 0.4;
filter: alpha(opacity=40);
}
Remove height: calc(100vh - 220px); from your content div.
Then, Just declare the div size and make the image size 100%.
#image{
height:200px;
width:200px;
}
#image img{
height:100%;
width:100%;
}
https://codepen.io/opmasan/pen/JjYxJgv
This variant with object-fit: contain and some fixes in html will be better:
#content #image img {
object-fit: contain;
}
I can't seem to figure out a way to stack my divs vertically while still aligning them in the center of the page.
This is my current html:
.loading-page {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.loading-page .image-container {
position: relative;
display: inline-block;
}
.loading-page .image-container .image-grey {
display: block;
-webkit-filter: grayscale(100%);
filter: grayscale(1);
}
.loading-page .image-container:after {
position: absolute;
content: "";
top: 0;
left: 0%;
width: var(--image-load);
height: 100%;
background-position: top left;
}
.counter {
text-align: center;
position: relative;
width: 200px;
}
.counter h1 {
color: black;
font-size: 60px;
font-weight: bold;
margin-top: -10px;
margin-bottom: -10px;
}
.counter hr {
background: #000000;
border: none;
height: 1px;
}
<div class="loading-page">
<div class="image-container" style="--image-load: 50%;">
<style>
.image-container:after {
background-image: url(http://i.imgur.com/bZt9ZwE.png);
}
</style>
<img class="image-grey" src="http://i.imgur.com/bZt9ZwE.png" />
</div>
<div class="counter">
<h1>50%</h1>
<hr/>
</div>
</div>
A working example:
JsFiddle
The target is for the "50%" text to be below the image while both divs are centered, both vertically and horizontally. Image size is going to be dynamic thus I can't just set everything with fixed width/height and play with paddings.
Set flex-direction:column; to .loading-page
body{
margin:0px;
}
.loading-page {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.loading-page .image-container {
position: relative;
display: inline-block;
}
.loading-page .image-container .image-grey {
display: block;
-webkit-filter: grayscale(100%);
filter: grayscale(1);
}
.loading-page .image-container:after {
position: absolute;
content: "";
top: 0;
left: 0%;
width: var(--image-load);
height: 100%;
background-position: top left;
}
.counter {
text-align: center;
position: relative;
width: 200px;
}
.counter h1 {
color: black;
font-size: 60px;
font-weight: bold;
margin-top: -10px;
margin-bottom: -10px;
}
.counter hr {
background: #000000;
border: none;
height: 1px;
}
<div class="loading-page">
<div class="image-container" style="--image-load: 50%;">
<style>
.image-container:after {
background-image: url(http://i.imgur.com/bZt9ZwE.png);
}
</style>
<img class="image-grey" src="http://i.imgur.com/bZt9ZwE.png" />
</div>
<div class="counter">
<h1>50%</h1>
<hr/>
</div>
</div>
Here you go!
Tip: don't use pixels(px), they can't be responsive... instead, use percentage as a unit of measurement to make it responsive.
EDIT: I Updated my answer... now it's responsive. Hope it helps!
.loading-page {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.loading-page .image-container {
position: relative;
display: inline-block;
}
.loading-page .image-container .image-grey {
display: block;
-webkit-filter: grayscale(100%);
filter: grayscale(1);
}
.loading-page .image-container:after {
position: absolute;
content: "";
top: 0;
left: 0%;
width: var(--image-load);
height: 100%;
background-position: top left;
}
.counter {
text-align: center;
position: static;
width: 200px;
}
.counter h1 {
color: black;
font-size: 60px;
font-weight: bold;
margin-top: 5%;
margin-bottom: -5%;
}
.counter hr {
background: #000000;
border: none;
height: 1px;
}
<div class="loading-page">
<div class="image-container"
style="--image-load: 50%;">
<style>.image-container:after { background-image: url(http://i.imgur.com/bZt9ZwE.png);}</style>
<img class="image-grey" src="http://i.imgur.com/bZt9ZwE.png"/>
</div>
<div class="counter">
<h1>50%</h1>
<hr/>
</div>
</div>
Whenever i try to move separator up or down, the element h1 above .separator class starts moving along with the separator. Is there any easy way to get rid of this issue?
Below is my HTML/CSS Code
.banner img {
width: 100%;
height: 100%;
}
.banner {
position: relative;
margin: -0.6%
}
.OverLay {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.OverLayContent {
width: 100%;
height: 100%;
display: table;
}
.overLayDescription {
width: 70%;
margin: 0 auto;
}
.OverLayText {
width: 100%;
height: 100%;
display: table-cell;
vertical-align: middle;
text-align: center;
}
.OverLayText h1 {
margin-bottom: 5%;
color: #FFF;
font-size: 120px;
/*border-bottom: 2px solid #15a4fa;*/
}
.separator {
margin: 0 auto;
width: 50%;
background-color: #15a4fa;
height: 2px;
margin-bottom: 10.4%;
}
.OverLayText a {
color: #FFF;
border: 1px solid #15a4fa;
padding: 10px;
}
.OverLayText p {
color: #FFF;
margin-top: 2%;
margin-bottom: 3%;
}
.OverLayContent {
position: relative;
}
<div class="banner">
<img src="http://cometoart.com/wp-content/uploads/2016/03/pojo-placeholder-2.png" />
<div class="OverLay">
<div class="OverLayContent">
<div class="OverLayText">
<h1>STRICT</h1>
<dir class="separator"></dir>
<p>STRICT is a responsive theme with a a clean and minimal look.</p>
Call to action
</div>
</div>
</div>
</div>
Just because you are using .OverLayText to vertically-align:middle;.
.banner img {
width: 100%;
height: 100%;
position: relative;
}
.banner {
position: relative;
margin: -0.6%
}
.OverLay {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.OverLayContent {
width: 100%;
height: 100%;
display: table;
}
.overLayDescription {
width: 70%;
margin: 0 auto;
}
.OverLayText {
width: 100%;
height: 100%;
display: table-cell;
vertical-align: middle;
text-align: center;
vertically-align:middle;
}
.OverLayText h1 {
margin-bottom: 5%;
color: #FFF;
font-size: 120px;
/*border-bottom: 2px solid #15a4fa;*/
}
.separator {
/*margin: 0 auto;*/
width: 50%;
background-color: #15a4fa;
height: 2px;
/*top: 80%;*/
position: relative;
margin: auto;
text-align: center;
display: block;
}
.OverLayText a {
color: #FFF;
border: 1px solid #15a4fa;
padding: 10px;
}
.OverLayText p {
color: #FFF;
margin-top: 2%;
margin-bottom: 3%;
}
.OverLayContent {
position: relative;
}
<div class="banner">
<img src="http://cometoart.com/wp-content/uploads/2016/03/pojo-placeholder-2.png" />
<div class="OverLay">
<div class="OverLayContent">
<div class="OverLayText">
<h1>STRICT</h1>
<dir class="separator"></dir>
<p>STRICT is a responsive theme with a a clean and minimal look.</p>
Call to action
</div>
</div>
</div>
</div>
did this for my homepage and wanted to background image content to be the middle of the image as the display size decreases (right now it slides the content of the image to the left). Thought of media query but Client only allows for one add-on of CSS, not different stylesheet files.
Also, although stated * margin= 0; padding=0 a margin appears on my smartphone (Iphone 6) and want it to be clear full screen as in desktop. Make browser pretty small to see if from laptop/desktop.
It has to be CSS ONLY since my client (Smugmug) only allows for blocks of css and html on it, no javascript or whatsoever. Also adds its own CSS to the page so I can post the link if needed.
Any idea for the dynamic positioning of the images and the margins? Thanks!
html,
body {
height: 100%;
width: 100%;
margin: 0;
padding; 0;
}
body {
display: flex;
flex-direction: column;
}
h1 {
margin: 0;
}
a {
display: inline-block;
}
#business-top {
display: flex;
flex: 1;
height:50vh;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
background-image : url(https://lluisballbe.smugmug.com/Assets-for-website/i-2KvXfrk/0/X3/_MG_9556-X3.jpg
);
background-size:cover;
}
#business-button {
transition: all 1s;
-webkit-transition: all 1s;
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
text-align:center;
}
#logo-separator {
text-align: center;
top: calc( 50%-height_of_separator)px;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
flex: 0;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin: auto;
max-width: 150px;
display: inline-block;
overflow: hidden;
margin: -75px;
position: absolute;
z-index:1;
}
#photography-bottom {
display: flex;
flex: 1;
width: 100%;
height:50vh;
align-items: center;
justify-content: center;
background-image : url(https://lluisballbe.smugmug.com/Assets-for-website/i-gPg5QBt/0/X3/_DSC5313-X3.jpg
);
background-size:cover;
}
#photography-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
h1 {
color: #ff7600;
text-align: center;
font-size: 1.4em;
vertical-align: middle;
line-height: 2.2em
}
#business-top,
#photography-bottom {
pointer-events: none;
position: relative;
transition: 1s;
min-height: 200px;
}
#business-top a,
#photography-bottom a {
pointer-events: auto;
}
<div id="business-top">
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"> </div>
</div>
<div id="photography-bottom">
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
you need to use background-position if you want to position a background image.
html,
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: column;
}
h1 {
margin: 0;
}
a {
display: inline-block;
}
#business-top {
display: flex;
flex: 1;
height:50vh;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
background-position: center center;
background-image : url(https://lluisballbe.smugmug.com/Assets-for-website/i-2KvXfrk/0/X3/_MG_9556-X3.jpg
);
background-size:cover;
}
#business-button {
transition: all 1s;
-webkit-transition: all 1s;
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
text-align:center;
}
#logo-separator {
text-align: center;
top: calc( 50%-height_of_separator)px;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
flex: 0;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin: auto;
max-width: 150px;
display: inline-block;
overflow: hidden;
margin: -75px;
position: absolute;
z-index:1;
}
#photography-bottom {
display: flex;
flex: 1;
width: 100%;
height:50vh;
align-items: center;
justify-content: center;
background-position: center center;
background-image : url(https://lluisballbe.smugmug.com/Assets-for-website/i-gPg5QBt/0/X3/_DSC5313-X3.jpg
);
background-size:cover;
}
#photography-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
h1 {
color: #ff7600;
text-align: center;
font-size: 1.4em;
vertical-align: middle;
line-height: 2.2em
}
#business-top,
#photography-bottom {
pointer-events: none;
position: relative;
transition: 1s;
min-height: 200px;
}
#business-top a,
#photography-bottom a {
pointer-events: auto;
}
<div id="business-top">
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"> </div>
</div>
<div id="photography-bottom">
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
add this css property to your both divs
background-position: center;
as example like this
#business-top {
display: flex;
flex: 1;
height:50vh;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
background-image : url(https://lluisballbe.smugmug.com/Assets-for-website/i-2KvXfrk/0/X3/_MG_9556-X3.jpg);
background-position: center;
}
do like this for your other div and try.