I am trying to make a full width hero image with an h1 header, boxed text with 2 sizes of text inside plus a button. I have been wrestling with this all day and it just doesnt seem to work the way i'd like it to. Any help would be really appreciated.
thanks
Images:
How it looks at the moment with code
If you notice it is not going full width (gap on the left).
This is how i would like it to look or close enough
//css//
.hero-image {
background-image: url("image.jpg");
background-position: 100%;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
padding: 50px;
}
.hero-text {
position: relative;
color: #154774;
}
.hero-text button {
border-radius: 5px;
padding: 10px 20px;
color: white;
background-color: #00adee;
text-align: center;
cursor: pointer;
font-size: 20px;
font-weight: bold;
bottom: 50px;
}
.hero-text button:hover {
background-color: #0597c4;
color: white;
}
.herotext2 {
border-radius: 5px;
padding: 10px 10px 10px 10px;
color: white;
background-color: red;
font-size: 20px;
width: 200px;
line-height: 1.4;
}
</style>
//html//
<div class="hero-image">
<div class="hero-text">
<h1 style="font-size:40px">IT support for<br>your business<br>as easy as<br>child’s play</h1>
<p class="herotext2">All inclusive IT GDPR service packages from £33 p/m</p>
<button>Try it for free today</button>
</div>
</div>
Updated image:
Updated image
.hero-image {
background-image: url("https://beerdeluxe.com.au/hawthorn/wp-content/uploads/sites/4/2017/05/hero-placeholder.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
padding: 50px;
}
.hero-text {
position: relative;
color: #154774;
text-align:right;
}
.hero-text h1 {
font-size:40px;
margin-right:15%;
}
.hero-text h1 .italic {
font-style: italic;
}
.hero-text button {
border-radius: 5px;
padding: 10px 20px;
color: white;
background-color: #00adee;
text-align: center;
cursor: pointer;
font-size: 20px;
font-weight: bold;
bottom: 50px;
max-width: 150px;
margin-top: 25px;
}
.hero-text button:hover {
background-color: #0597c4;
color: white;
}
.herotext2 {
position:relative;
border-radius: 5px;
padding: 10px 10px 10px 10px;
color: white;
background-color: red;
font-size: 20px;
width: 200px;
line-height: 1.4;
margin: 0 0 0 auto;
text-align:left;
}
.herotext2 .no {
font-size: 135px;
line-height: 130px;
font-weight: 600;
}
.herotext2 .tag {
position: absolute;
bottom: 26px;
right: 30px;
font-size: 12px;
color: red;
}
<div class="hero-image">
<div class="hero-text">
<h1>IT support for your<br> business - <span class="italic">as easy as<br>child’s play</span></h1>
<p class="herotext2">All inclusive IT GDPR service packages from <span class="no">£33</span><span class="tag">p/m</span></p>
<button>Try it for free today</button>
</div>
</div>
https://jsfiddle.net/Sampath_Madhuranga/pwxf73z8/16/
I have updated your html format and added new styles..Now it appears as your design but you need to apply relevant font family.
It works nice. Let me know if there is any issue.
Thanks.
You are missing absolute positioning the elements inside the hero image. This way, you can force them to stay at certain point inside it, by setting top, right, bottom and left of each one.
Don't forget to set parent hero div to position: relative.
Related
I am trying to fix an svg icon in the bottom right corner of my hero banner (using flexbox). I am struggling to pin it into the correct position and also need to be able to adjust its position relative to the text and button (its a responsive website and I need to adjust based on screen size). I tried to adjust with the css margin property (left and right), but it does not work well.
.hero {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100vh;
padding: 1em;
box-sizing: border-box;
color: #333333;
background: url(https://images.unsplash.com/photo-1500417148159-68083bd7333a) center center no-repeat;
background-size: cover;
}
.hero-title {
max-width: 17em;
margin: 0;
font-size: 8vh;
font-weight: 100;
line-height: .9;
padding-left: 93px;
padding-top: 150px;
text-transform: none;
color: white;
}
.hero-subtitle {
max-width: 23em;
margin: 0;
font-size: 2vh;
font-weight: 100;
line-height: 1.3;
padding-left: 100px;
padding-bottom: 100px;
padding-top: 60px;
color: white;
}
.hero-footer {
display: flex;
margin-bottom: 2.5em;
}
/* button */
.button-primary {
color: red;
background-color: transparent;
padding: 8px 25px;
margin-left: 100px;
margin-bottom: 350px;
text-decoration: none;
border: .1em solid red;
font-size: 12px;
}
.button-primary:hover {
color: #ffffff;
background-color: #333333;
border: .1em solid #ffffff;
}
#iconheader {
display: flex;
flex-direction: column;
align-items: flex-end;
}
#myicon {
text-decoration: none;
font-size: 5vh;
font-weight: bold;
background: url(../images/test_icon.svg) 50% 50% no-repeat;
color: white;
}
<section class="hero">
<header id="header">
</header>
<header class="hero-header">
<h1 class="hero-title">Wonderful Day<br>Amazing Forum<br>Great Friends</h1>
</header>
<header class="hero-header">
<h2 class="hero-subtitle">Stackoverflow is the #1 forum among developers. Just ask anyone. </h2>
</header>
<footer class="hero-footer">
<a class="button-primary" href="#">Learn More</a>
<div id="iconheader">
<a id="myicon" href="#">Icon</a>
</div>
</footer>
</section>
Any help or suggestions would be greatly, greatly appreciated! Thank you.
Set position absolute and zindex high
.hero {
position: relative;
}
#iconheader {
position: absolute;
right: 0;
bottom: 0;
z-index:99999
}
for set a svg icon bottom in right corner use this css rules instead of yours:
#iconheader {
position: absolute;
right: 0;
bottom: 0;
}
in this way, the svg is always there
I need to move navbar onto image. I've tried to set position: absolute; for navbar but it collapsed. How can I do this?
* {
margin: 0;
padding: 0;
}
body {
font-family: "Montserrat", sans-serif;
}
.global-padding {
padding: 0 98px;
}
.container {
width: 1172px;
margin: 0 auto;
}
.order-us-button {
display: inline-block;
width: 212px;
height: 45px;
text-align: center;
text-decoration: none;
letter-spacing: 3.6px;
text-transform: uppercase;
color: #212121;
border-radius: 23px;
background-color: #ffffff;
box-shadow: 0 2px 5px 1px rgba(33, 33, 33, 0.35);
font-size: 18px;
font-weight: 700;
line-height: 45px;
}
.navbar {
display: flex;
padding-top: 63px;
flex-wrap: wrap;
justify-content: space-between;
}
.navbar_fixed {
/* pass */
}
.navbar__logo-img {
-webkit-user-drag: none;
-khtml-user-drag: none;
-moz-user-drag: none;
-o-user-drag: none;
}
.navbar__menu {
display: flex;
list-style: none;
}
.navbar__menu-link {
padding: 10px 13px;
text-decoration: none;
text-transform: uppercase;
color: #8c8c8c;
font-size: 14px;
font-weight: 300;
}
.navbar__menu-link_active {
letter-spacing: 1.4px;
color: #212121;
border-bottom: 3px solid #212121;
font-weight: 700;
}
.navbar__search {
padding: 0;
border: none;
background: none;
}
.navbar__search-icon {
-webkit-user-drag: none;
-khtml-user-drag: none;
-moz-user-drag: none;
-o-user-drag: none;
}
.slider__background-image {
width: 100vw;
height: 100vh;
}
.slider__text {
position: absolute;
}
.slider__status-text {
text-transform: uppercase;
color: #ffffff;
font-size: 18px;
font-weight: 700;
}
.status-text_trending {
color: #43a047;
}
.slider__h2 {
text-transform: uppercase;
color: #212121;
font-size: 62px;
font-weight: 100;
line-height: 72px;
}
.slider__content {
width: 450px;
color: #6c6c6c;
font-size: 14px;
font-weight: 300;
line-height: 24px;
}
.slider__circle {
display: inline-block;
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #c7c7c7;
}
.slider__circle_active {
width: 40px;
height: 40px;
background-color: #212121;
}
<div class="slider">
<nav class="navbar global-padding">
LOGO
<ul class="navbar__menu">
<li class="navbar__menu-item">HOME</li>
<li class="navbar__menu-item">PRODUCTS</li>
<li class="navbar__menu-item">HISTORY</li>
<li class="navbar__menu-item">SHOWROOM</li>
<li class="navbar__menu-item">CONTACT</li>
<button class="navbar__search"><img class="navbar__search-icon" src="{% static 'img/search.svg' %}" alt="Search"></button>
</ul>
</nav>
<img src="https://images.pexels.com/photos/1350789/pexels-photo-1350789.jpeg?cs=srgb&dl=two-assorted-color-padded-chairs-near-side-table-1350789.jpg&fm=jpg" alt="Slider image" class="slider__background-image">
</div>
You should rather set img to position: absolute instead of navbar. Keep in mind you'd need img's parent container to be set to position: relative.
Edit 1-
You might also need to set z-index for img if it blocks navbar from appearing.
Edit 2-
For the navbar going out of screen issue-
Use width: 100vw for nav element
Set flex-grow: .5 and flex-basis: 50% to ul in the nav element
Note- You can adjust the amount of flex-grow and flex-basis to whatever you want.
Your code have some serious problems which indicates lack of experience, and they are as follows-
1- why you want to specify image differently and position it onto navbar? Instead you can use background-image: url(''); property with the parent container and your desired result will be achieved.
2- If you want gap between logo and image then don't specify it with a particular margin. Kindly use float:right; for links and float: left; for your logo, then you can specify margins to any specific link just as you want it to be.
3- Kindly make us clear about your actual query and share the snippet of essential information only!
you should first make your code clear and up to the point, and then kindly specify your queries in details.
If you want an image in navbar?
add width="50px";
<img width="50px" alt="Search">
You also can set the Image as css Background image
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif
}
nav{
display: flex;
justify-content: space-between;
align-items: flex-start;
color: red;
background-image: url(https://images.pexels.com/photos/1350789/pexels-photo-1350789.jpeg?cs=srgb&dl=two-assorted-color-padded-chairs-near-side-table-1350789.jpg&fm=jpg);
height: 50vw;
background-size: 100% 100%;
background-repeat: no-repeat;
padding: .5rem;
}
.nav-container a{margin: 0 .3rem; color: red}
<nav><h3>Company</h3><div class="nav-container">AboutHistoryPricing<div></nav>
Try this
<button class="navbar__search" style="background-image: url('your_image.jpg');">Search</button>
in your_image specify the image you wish to be displayed.
remove img tag and check it.
I'm currently making a project which consists of a website that streams movies and tv shows, in the tv show section I want to insert a image to illustrate each episode. My idea is making a second image that shows which episode that image corresponds to and I'm having a little trouble putting the second image above the first one.
.episode-slidebackground {
width: 950px;
height: 220px;
background: rgba(162, 162, 162, 0.24);
float: left;
margin-left: 15px;
margin-top: 20px;
margin-bottom: 15px;
}
.episode-slidebackground img {
width:182px;
height:136px;
float: left;
margin-left: 7px;
margin-top: 7px;
margin-bottom: 5px;
border-radius: 15px;
}
.episode-slideimgbackground{
width: 925px;
margin-left:10px;
margin-right:10px;
height:145px;
background: rgba(128, 128, 128, 0.24)
}
h1{
font-size: 30px;
color: #f2a223;
font-weight: bold;
margin-bottom: 30px;
margin-top: 10px;
}
h2 {
font-size: 15px;
color: #f2a223;
font-weight: bold;
}
h3 {
font-size: 14px;
color: #fff;
font-weight: bold;
}
h4 {
font-size: 14px;
color: #f3b12b;
font-weight: bold;
}
h5 {
font-size: 12px;
color: white;
}
h6 {
font-size: 20px;
color: white;
padding-left: 5px;
padding-top: 5px;
}
<div class="episode-slidebackground">
<h6>Temporada:1 2 3 4 5 6</h6> <br>
<h2>Episódios:</h2>
<div class="episode-slideimgbackground">
<img src="img/1.jpg">
<img src="img/2.jpg">
<img src="img/3.jpg">
</div>
</div>
This is the page without the second image:
You need to try and work with CSS's position attribute. This will enable you to have more control over your elements.
The two position attribute's you need to make use of are absolute and relative.
Basically, if you have a div that is set to position: relative that means that you can adjust that div's position without changing the layout of your webpage. It also means that any children elements of that div with the position: absolute can be positioned anywhere inside of that relative div.
.videoContainer {
position: relative;
height: 200px;
width: 200px;
}
.videoImage, .videoCaption {
position: absolute;
color: white;
}
.videoCaption {
bottom: 0;
height: 50px;
background: Gray;
width: 100%;
}
<div class="videoContainer">
<img class="videoImage" src="http://placehold.it/200x200"/>
<div class="videoCaption">Some Caption</div>
</div>
You need to set the z-index this is an css attribute that determines which element is on top
https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
I have a button on my website, and I used resolution independent alignment. I checked two different computer screens with different resolutions and it looks alright, however, once opened on a larger aspect ratio screen or a mobile/tablet device it re-positions. On a larger aspect ratio screen the buttons moves to the left, on the smaller devices, it floats towards the right. I'm not 100% certain what could of gone wrong. Below is my CSS and HTML code.
HTML:
<div class="Welcome">
<h1>Welcome to Beauty Factory Bookings</h1>
<button>Book Appointment</button>
</div>
CSS:
body {
background: url('http://i.imgur.com/4mKmYMb.jpg') no-repeat fixed center center;
background-size: cover;
font-family: Montserrat;
margin: 0;
padding: 0;
.Welcome {
margin-top: 13%;
}
.Welcome h1 {
text-align: center;
font-family: Montserrat;
font-size: 50px;
text-transform: uppercase;
}
.Welcome button {
height: 60px;
width: 340px;
background: #ff656c;
border: 1px solid #e15960;
color: #fff;
font-weight: bold;
text-transform: uppercase;
font-size: 17px;
font-family: Montserrat;
outline: none;
cursor: pointer;
text-align: center;
margin-left: 33%;
margin-top: 3%;
border-radius: 5px;
}
Any idea how to fix this?
You center a html element, which has the standard position and is a block element with margin-left: auto and margin-right: auto.
It is a convention to write the first letter of classes and ids in lowercase.
Example
Just another way to do it:
I wrap your button in div and center the button using text-align:center
Don't forget to take out margin-left: 33%; in your css
HTML
<div class="Welcome">
<h1>Welcome to Beauty Factory Bookings</h1>
<div class="center">
<button>Book Appointment</button>
</div>
</div>
CSS
.Welcome {
margin-top: 13%;
}
.Welcome h1 {
text-align: center;
font-family: Montserrat;
font-size: 50px;
text-transform: uppercase;
}
.center {
text-align: center;
}
.Welcome button {
height: 60px;
width: 340px;
background: #ff656c;
border: 1px solid #e15960;
color: #fff;
font-weight: bold;
text-transform: uppercase;
font-size: 17px;
font-family: Montserrat;
outline: none;
cursor: pointer;
text-align: center;
margin-top: 3%;
border-radius: 5px;
}
Example: http://codepen.io/anon/pen/EPyjXm
create a new CSS property for a tag and set display to flex(takes up 100% of width; and justify content to center.
EDIT
After checking out your site,
there is a margin-left of 15px coming from somewhere. Get rid of it if that is a possibility or else just add margin-left: 0 to the .Welcome a {...}
.Welcome a {
display: flex;
/*set display mode of anchor to flex*/
justify-content: center; /* Justify content center*/
margin-left: 0; /* Add !important in case it is overwritten*/
}
.Welcome {
margin-top: 13%;
}
.Welcome h1 {
text-align: center;
font-family: Montserrat;
font-size: 50px;
text-transform: uppercase;
}
.Welcome a {
display: flex;
/*set display mode of anchor to flex*/
justify-content: center; /* Justify content center*/
}
.Welcome button {
height: 60px;
width: 340px;
background: #ff656c;
border: 1px solid #e15960;
color: #fff;
font-weight: bold;
text-transform: uppercase;
font-size: 17px;
font-family: Montserrat;
outline: none;
cursor: pointer;
text-align: center;
border-radius: 5px;
}
<div class="Welcome">
<h1>Welcome to Beauty Factory Bookings</h1>
<a href="website_link">
<button>Book Appointment</button>
</a>
</div>
I am trying to inserting an image which is the & symbol but it wont seem to be appearing within my html.
My HTML code is :
<section style= "background: #FEFEFE;" id="intro">
<b>" We are a digital marketing shop that creates marketing solutions" <br>
<br>
As designers, programmers <span> & </span> problem solvers, we love all things
</b>
</section>
CSS:
#intro {
height: auto;
padding: 50px 0;
background: #fff;
text-align: center;
color: #52626e;
font-size: 30px;
font-weight: normal;
}
#intro span {
background: url(../images/icons.png) no-repeat -0px -13px;
padding: 0 12px;
text-indent: -9999em;
display: inline-block;
*display:inline;
}
#intro {
height: auto;
padding: 50px 0;
background: #fff;
text-align: center;
color: #52626e;
font-size: 30px;
line-height: 36px;
font-weight: normal;
}
#intro span {
background: url(http://www.makeyourowngarments.com/sites/default/files/our_images/&%20sign.png) no-repeat;
background-size: 36px;
width: 36px;
text-indent: -9999em;
display: inline-block;
}
take a look at the quick and dirty example on jsfiddle