slogan and background image attach responsively - html

I am trying to design such header where the slogan and background image are attached in the stated picture. I want to use flex to make it work but it is not working. Giving width breaks the responsiveness. I have created a jsbin to show the demo and here it is
http://jsbin.com/muguwavosa/edit?html,css,output
The source code
.header {
display: flex;
flex-direction: column;
background-image: url('https://www.rj-investments.co.uk/wp-content/uploads/2018/02/Home-Featured.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
padding: 100px 0;
}
.slogan-wrapper {
background: #fff;
padding: 80px 0 0 40px;
margin-top: 70px;
}
.slogan-text > h1 {
font-size: 3.375rem;
font-weight: 900;
letter-spacing: 5px;
color: #373f48;
}
.slogan-text {
padding: 100px 70px 100px 0;
position: relative;
background: #fff;
z-index: 1;
}
<div class="header">
<div class="slogan-wrapper grid">
<div class="slogan">
<div class="slogan-text">
<h1>Hustle, Loyalty, Respect</h1>
</div>
</div>
</div>
This is what I wanted exactly and its a full width header

Did you notice that the class 'span' div is closed with a p tag? If you wanted to put the width there then that would be the problem.

Change the below code in CSS file and try once.
.header {
display: flex;
flex-direction: column;
background-image: url('https://www.rj-investments.co.uk/wp-content/uploads/2018/02/Home-Featured.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
padding: 100px 0;
}
.slogan-wrapper {
margin-top: 70px;
}
.slogan-text > h1 {
font-size: 3.375rem;
font-weight: 900;
letter-spacing: 5px;
color: #373f48;
background-color: #fff;
padding: 80px 40px;
width: auto;
max-width: 319px;
}
.slogan-text {
padding: 100px 30px 100px 0;
position: relative;
z-index: 1;
}

Related

CSS - avoid more than 16px space between text node and span

I have this elements.
<div class="container">
<h2>
Stackoverflow is a QA website<span class="link"></span>
</h2>
</div>
There must be only 1rem (16px) space between the span element and the text node irrespective of the width of the h2 element.
I have used the following CSS, but it does not work. The span element is on the right side. There is more than 1rem space between the text and the span.
html {
font-size: 16px;
}
.container {
max-width: 500px;
}
h2 {
font-size: 2.25rem;
line-height: 3rem;
margin-bottom: 1.5rem;
position: relative;
display: flex;
justfiy-content: flex-start;
}
h2>span.link {
display: flex;
visibility: hidden;
justify-content: center;
align-items: center;
cursor: pointer;
position: relative;
align-self: center;
margin-left: 1rem;
width: 40px !important;
height: 40px !important;
border-radius: 20px;
background: #eee;
-webkit-mask-image: radial-gradient(white, black);
overflow: hidden;
}
h2:hover>span.link {
visibility: visible;
}
span.link:after {
position: absolute;
right: 0;
bottom: 0;
top: 0;
left: 0;
content: "";
border-radius: 20px;
width: 40px !important;
height: 40px !important;
background-image: url("data:image/svg+xml;utf-8, <svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' viewBox='0 0 105 105' version='1.1' xml:space='preserve' style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'><g id='Medium-M' transform='matrix(1,0,0,1,-11.233,88.1885)'><path fill='#616161' d='M65.882,-56.192L58.465,-48.713C61.394,-48.446 63.917,-47.856 66.032,-46.941C68.147,-46.027 69.95,-44.822 71.439,-43.326C74.195,-40.549 76.033,-37.497 76.954,-34.168C77.875,-30.839 77.884,-27.519 76.983,-24.206C76.082,-20.894 74.256,-17.862 71.506,-15.112L55.276,1.07C52.526,3.819 49.494,5.651 46.182,6.566C42.869,7.481 39.55,7.486 36.224,6.582C32.898,5.678 29.86,3.848 27.11,1.092C24.355,-1.685 22.516,-4.737 21.596,-8.066C20.675,-11.395 20.672,-14.714 21.587,-18.024C22.502,-21.333 24.334,-24.366 27.084,-27.122L35.468,-35.497C34.69,-37.256 34.189,-39.165 33.963,-41.226C33.737,-43.287 33.836,-45.262 34.261,-47.15L20.23,-33.194C16.251,-29.206 13.589,-24.795 12.244,-19.96C10.9,-15.126 10.896,-10.284 12.233,-5.433C13.571,-0.583 16.253,3.853 20.279,7.874C24.333,11.933 28.783,14.628 33.631,15.96C38.478,17.292 43.318,17.285 48.149,15.94C52.981,14.595 57.38,11.939 61.348,7.972L78.328,-9.04C82.322,-13.034 84.992,-17.449 86.337,-22.283C87.681,-27.117 87.687,-31.958 86.352,-36.806C85.018,-41.653 82.324,-46.088 78.271,-50.108C76.852,-51.559 75.142,-52.802 73.141,-53.837C71.139,-54.871 68.72,-55.656 65.882,-56.192ZM61.585,-15.044L69.002,-22.523C66.072,-22.79 63.551,-23.38 61.439,-24.295C59.326,-25.209 57.523,-26.412 56.027,-27.901C53.245,-30.684 51.393,-33.74 50.473,-37.069C49.552,-40.397 49.551,-43.716 50.468,-47.026C51.386,-50.336 53.22,-53.365 55.97,-56.115L72.16,-72.297C74.937,-75.053 77.981,-76.888 81.294,-77.803C84.606,-78.717 87.917,-78.721 91.227,-77.814C94.537,-76.907 97.583,-75.065 100.365,-72.288C103.115,-69.532 104.95,-66.491 105.871,-63.165C106.792,-59.839 106.795,-56.52 105.88,-53.208C104.965,-49.895 103.132,-46.864 100.383,-44.114L92.007,-35.739C92.785,-33.954 93.287,-32.037 93.513,-29.99C93.739,-27.943 93.639,-25.972 93.214,-24.078L107.245,-38.042C111.224,-42.03 113.885,-46.442 115.227,-51.276C116.568,-56.11 116.571,-60.951 115.234,-65.799C113.897,-70.647 111.217,-75.084 107.196,-79.111C103.137,-83.164 98.685,-85.858 93.84,-87.192C88.995,-88.526 84.157,-88.521 79.326,-87.176C74.495,-85.832 70.079,-83.159 66.079,-79.159L49.148,-62.196C45.147,-58.197 42.476,-53.781 41.135,-48.949C39.793,-44.118 39.788,-39.278 41.119,-34.431C42.45,-29.583 45.143,-25.149 49.197,-21.128C50.621,-19.677 52.334,-18.433 54.335,-17.395C56.336,-16.357 58.753,-15.574 61.585,-15.044Z' style='fill-rule:nonzero;'/></g></svg>");
background-repeat: no-repeat;
background-position: center;
background-size: 15px 15px;
}
<div class="container">
<h2>
Stackoverflow is a QA website<span class="link"></span>
</h2>
</div>
span:after contains a svg icon. I need to keep the icon. But it does not seem to work here. That is not the issue.
I need to avoid having more than 1rem space between the text node and the span element. How to fix it?

Background image isn't displaying full resolution

I have a background image that's about 1200 (w) x 800 (h) but i just want to use the whole 100% resolution for it. I have a button inside this div container but it's not displaying correctly. The background image won't expand to it's full resolution. It seems like it's only showing enough to allow the button to show.
.endFoot {
background-image: url('https://via.placeholder.com/900x900');
background-size: cover;
width: 100%;
height: 100%;
}
.customButton {
position: relative;
bottom: 0;
left: 41%;
padding: 25px 35px;
font-size: 16px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
<div class="endFoot">
<button class="customButton">TEXT</button>
</div>
here's a little picture demonstrating what's going wrong vs what i want:
This has nothing to do with background image not expanding. Your div is simply not tall enough to show more of the image. Going off of your diagram, you want to add some padding to .endFoot.
background-size: cover; is a good choice, but you may also want to consider centering the position with background-position: 50% 50%;.
.endFoot {
background-image: url('https://via.placeholder.com/900x900');
background-size: cover;
background-position: 50% 50%;
width: 100%;
background-repeat: no-repeat;
padding: 400px 0 0 0;
height: 100%;
}
.customButton {
position: relative;
bottom: 0;
left: 41%;
padding: 25px 35px;
font-size: 16px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
<div class="endFoot">
<button class="customButton">TEXT</button>
</div>
If you would like the endFoot div to have the same height as the background, just set the height to 800px, because 100% doesn't change anything in this case.
Also set the endFoot position to relative in order to put the botton to the correct position.
If you are trying to achieve full screen background try :
.endFoot {
width: 100vw;
height: 100vh;
}
For browser support informations of vh and vw units check : https://caniuse.com/#feat=viewport-units
Just add text-align:center to .endFoot class to make center button and add some margin to .customButton class for leave some space to bottom.
.endFoot {
background-image: url('https://via.placeholder.com/900x900');
background-size: cover;
background-position: 50% 50%;
width: 100%;
background-repeat: no-repeat;
padding: 400px 0 0 0px;
height: 100%;
position: relative;
text-align: center;
}
.customButton {
padding: 25px 35px;
font-size: 16px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
margin-bottom: 10px;
}
<div class="endFoot">
<button class="customButton">TEXT</button>
</div>

Vertical align header page elements

I have header tag, which has full width/height image on the background.
I need to algin elements in the center of that page exactly as picture shows.
First goes image, than text, than buttons one after another one and on the very bottom of the page is slider
apart from slider, I've managed to put all content to the center with code below
Also, I'm using boostrap and jquery if needed
It's one page design, this is just a header
Thank you for any help :)
<header>
<img src="" alt="full">
<h1>The</h1>
Login
Browse
<div class="swiper-container">
</div>
</header>
SCSS
header {
margin-top: -56px !important;
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url(../img_cover_m.jpg);
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
img {
margin-top: 5%;
max-width: 50%;
height: auto;
}
h1 {
color: #fff;
}
.btn {
#include Myriad-Pro-Light;
}
.btn-green {
margin-top: 5%;
color: #fff;
}
.btn-grey {
color: #000;
}
.swiper-container {
margin-top: 5%;
width: 100%;
height: 300px;
}
}
You can achieve this by using the following properties at the appropriate places.
text-align:center;
display:flex;
align-center;
margin:0 auto;
Also as your using bootstrap so some of the classes may get overwritten so make sure to use !important on properties that you want to force your setting on.
Using your code i have made some changes using the above mentioned suggestions and here is the code:
<header>
<img src="http://placehold.it/350x150" alt="full">
<h1>The</h1>
Login
Browse
<div class="swiper-container">
<p>Large full width div, which must stay on the bottom of the header tag</p>
</div>
</header>
header {
background-image: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url(../img_cover_m.jpg);
background-size: cover;
background-position: center;
height: 100vh;
min-width: 20%;
display: flex;
flex-direction: column;
align-items: center;
}
img {
margin: 0 auto;
display: block;
max-width: 50%;
height: auto;
}
h1 {
color: #fff;
text-align:center;
}
.btn {
#include Myriad-Pro-Light !important;
margin: 10px auto !important;
display: block !important;
width: 25vw !important;
text-align:center !important;
padding: 6px 0px !important;
}
.btn-green {
color: #fff;
display:block;
}
.btn-grey {
color: #000;
display:block;
}
.swiper-container {
background-color:red;
width: 100%;
height: 300px;
position:absolute;
bottom:0;
display: flex;
align-items: center;
justify-content: center
}
.swiper-container p{
#include Myriad-Pro-Light !important;
margin:0 auto;
color:white;
font-size: 18px;
}
Here is a sample using this code. http://codepen.io/Nasir_T/pen/PboZme

html - Div alignment issues

So I am currently making a website for a friend of mine and I have set the left and right margin to 80px. This works for everything but my main body. It seems that it expands past the right margin, and simply has a margin of 60px instead of 80px.
Here is a screenshot: http://i.imgur.com/XtRdlUv.png
EDIT: I cut off some of the left margin, sorry for the confusion
As seen with the red arrow, there seems to be an offset when their shouldn't.
Here is my code:
body {
background: url(image) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
text-align: center;
margin-left: 80px;
margin-right: 100px;
}
.wrapper {
padding-top: 10px;
text-align: left;
margin: 0px auto;
}
.mainbody {
width: 100%;
outline: #293135 solid;
background-color: #444444;
margin-top: 40px;
text-align: left;
padding: 20px;
color: #FFFFFF;
}
<div class="mainbody" style="text-align: center">
<font face="Arial, Helvetica, sans" size="4">
<h1 style="text-decoration: underline">Download</h1>
<p>Features Include:</p>
</font>
</div>
You don't need
width: 100%;
Since .mainbody is a block element, it will expand to fill all the remaining space.
Otherwise, adding it produces the problem because of the content-box sizing model.
body {
background: url(image) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
text-align: center;
margin-left: 80px;
margin-right: 100px;
}
.wrapper {
padding-top: 10px;
text-align: left;
margin: 0px auto;
}
.mainbody {
outline: #293135 solid;
background-color: #444444;
margin-top: 40px;
text-align: left;
padding: 20px;
color: #FFFFFF;
text-align: center;
font-family: Arial, Helvetica, sans;
font-size: 18px;
}
<div class="mainbody" style="">
<h1 style="text-decoration: underline">Download</h1>
<p>Features Include:</p>
</div>
It is likely because your .mainbody element is using the default content-box, which adds an extra left and right padding of 20px each on top of the 100% width. Therefore, the final computed width of the element would be 100% + 40px, which causes it to 'overflow' of sorts.
To fix this, simply declare box-sizing: border-box, i.e.:
.mainbody {
box-sizing: border-box;
width: 100%;
outline: #293135 solid;
background-color: #444444;
margin-top: 40px;
text-align: left;
padding: 20px;
color: #FFFFFF;
}
In fact, it is recommended that you use this rule: * { box-sizing: border-box;} as recommended here.
I think you're using old ways. Try this! .mainbody { width: calc(100% - 120px); }
This is your new css and JSFiddle link! http://jsfiddle.net/Leo4v9rc/
body {
background: url(image) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
text-align: center;
}
.wrapper {
padding-top: 10px;
text-align: left;
margin: 0px auto;
}
.mainbody {
width: calc(100% - 120px);
outline: #293135 solid;
background-color: #444444;
margin:40px auto 0 auto;
text-align: left;
padding: 20px;
color: #FFFFFF;
}

Difficulty inserting a background image between header/footer

So I've set up my HTML and I've began to start styling accordingly, however I'm trying to create a fill/covering effect so my image fits between the header and footer and covers the screen however I get this problem. What I want is for it to cover the whole page/screen.
I'm sure it's an easy fix, I just can't figure it out!
http://s28.postimg.org/he9h8lae3/screene.png
Heres my code
HTML
`<body>
<header id="page-header">
<div class="container">
<h1></h1>
<h2></h2>
</div>
</header>
<section class="page-main">
<div class="container">
<div class ="main">
</div>
</div>
</section>
<footer id="page-footer">
<div class="container">
<h4></h4>
<nav>
<ul>
<li>Got Feedback?</li>
</ul>
</nav>
</footer>
</div><!-- #container -->
</body>
</html>
CSS
body {
color: #000;
font-family: 'Rokkitt', serif;
font-size: 1em;
line-height: 1.2;
width: 100%;
height: 100%; }
#container {
max-width: 1280px;
margin: auto; }
main { display: block }
h1 {
font-family: 'Montserrat', sans-serif;
font-size: 2em;
line-height: 1;
font-weight: bold; }
h2 {
font-size: 1.2em;
margin: 20px 0 20px 20px;
text-align: center; }
h3 { }
#page-header {
background-color: #FFB90F;
color: black;
overflow: hidden; }
#page-header h1 {
color: black;
margin: 20px 0 20px 20px;
text-align: center; }
.page-main {
background: url("../images/img_a.png") center center no-repeat;
height: auto;
background-size: cover;
overflow: hidden;
padding: 3%;
box-shadow: inset 0 0 5px rgba(0,0,0,.75); }
#page-footer {
background: #282828;
color: white; }
#page-footer nav { text-align: right; }
#page-footer nav li {
color: white;
display: block; }
#page-footer nav a {
color: white;
display: block;
margin-right: 20px; }
If you want to cover the space you may want to look into the CSS3 background-size.
element{
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
CSS
I am assuming the background image is attached to div.container
.container{
background-image: url('Whateveryoururlis');
height: HeightofImage;
width: widthofImage;
}
Height and width are important.