html css creating link to background - html

I'm an iOS developer and not a web developer. I'm trying to create my website to promote my apps and am trying to attach a link to the background image defined in CSS as #hero. I did some researching and found some examples where the css defines the background as .photo with the associated properties...but my structure is laid out with the # and multiple sections. I've tried experimenting with different combinations like a blind person in the dark and couldn't manage to get anything working in the way I need it. Looking for some help.
<!-- ======= Hero Section ======= -->
<section id="hero" class="d-flex flex-column justify-content-center align-items-center">
<div class="hero-container" data-aos="fade-in">
Hero
</div>
</section><!-- End Hero -->
CSS COde below
.header {
border-bottom:1px solid #eaeaea;
}
.header a {
display: block;
background-image: url("./images/embouchure.jpg");
background-repeat: no-repeat;
height:160px;
padding-left:280px;
padding-top:50px;
width:470px;
color: #eaeaea;
}
#hero {
width: 100%;
height: 100vh;
background: url("../img/hero-bg.jpg") top center;
background-size: cotain;
background-repeat: no-repeat;
}
#hero:before {
content: "";
background: rgba(5, 13, 24, 0.3);
position: absolute;
bottom: 0;
top: 0;
left: 0;
right: 0;
z-index: 1;
}
#hero .hero-container {
position: relative;
z-index: 2;
min-width: 300px;
}
#hero h1 {
margin: 0 0 10px 0;
font-size: 64px;
font-weight: 700;
line-height: 56px;
color: #fff;
}
#hero p {
color: #fff;
margin-bottom: 50px;
font-size: 26px;
font-family: "Poppins", sans-serif;
}
#hero p span {
color: #fff;
padding-bottom: 4px;
letter-spacing: 1px;
border-bottom: 3px solid #149ddd;
}
#media (min-width: 1024px) {
#hero {
background-attachment: fixed;
}
}
#media (max-width: 768px) {
#hero h1 {
font-size: 28px;
line-height: 36px;
}
#hero h2 {
font-size: 18px;
line-height: 24px;
margin-bottom: 30px;
}
}

you can achieve it by
javascript
$(".hero-container").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
or you can try like
<a href="https://google.com">
<div class="hero-container">
anything
</div>
</a>
Or, you could set a data-* attribute on the
<div data-location="https://google.com">
and do like:
window.location = $(".hero-container").data("location");

Related

How to fix an icon in a corner of hero banner for responsive design?

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

Responsive hero image with button + boxed text problems

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.

All new HTML appears behind an image?

I have been working on a responsive web design, after adding CSS to make a link stay centered on a an image the webpage now displays any new html behind the image. I want to be able to add more things on my webpage but any new html I write disappears.
Link to JSFIDDLEhttps://jsfiddle.net/R4bbit2k17/7yuL4y1p/1/#&togetherjs=MEzytpw3kf`
Because your .banner-inner is using position: absolute in conjunction with taking up 100% of the width and height, you'll need to set a position other than static for your text element(s), along with giving them a z-index greater than the default of 0:
p {
background: red; /* Purely to highlight the text */
position: relative;
z-index: 1;
}
This causes your text to appear on top of your image, and can be seen in the following:
body {
font-family: helvetica;
font-size: 15px;
line-height: 1.5;
padding: 0;
margin: 0;
background-color: #f4f4f4;
}
header {
background: black;
color: white;
padding-top: 20px;
min-height: 45px;
}
header a {
color: white;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header ul {
margin: 0;
padding: 0;
}
header li {
float: left;
display: inline;
padding: 0 20px 0 20px;
}
header nav {
float: right;
margin-top: 5px;
}
#media only screen and (max-width:1000px) {
.centered {
font-size: 12pt!important;
}
}
#media only screen and (max-width:800px) {
.centered {
font-size: 11pt!important;
}
}
#media only screen and (max-width:600px) {
.centered {
font-size: 10pt!important;
}
}
#media only screen and (max-width:400px) {
.centered {
font-size: 9pt!important;
}
}
#media only screen and (max-width:200px) {
.centered {
font-size: 8pt!important;
}
}
.banner-inner {
width: 100%;
height: 100%;
position: absolute;
text-align: center;
color: white;
}
.centered {
position: absolute;
margin-left: auto;
margin-right: auto;
width: 100%;
height: auto;
margin-top: 20%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-size: 12pt;
}
.img {
width: 100%;
height: auto;
float: left;
}
p {
background: red;
position: relative;
z-index: 1;
}
<body>
<header>
<div id="header-inner">
<nav>
<ul>
<li>Home</li>
<li>Courses</li>
<li>About</li>
</ul>
</nav>
</div>
</header>
<section class="section-1">
<div class="banner-inner">
<img class="img" alt="" src="https://d2mt0dng9y3p4j.cloudfront.net/newandimproved/wp-content/uploads/2016/12/shop-with-a-sheriff-mockup.jpg">
<div class="centered">Start Learning</div>
</div>
</section>
<p>ANY HTML ADDED APPEARS BEHIND THE IMAGE AND I CANNOT FIGURE OUT HOW TO CHANGE IT TO APPEAR BENEATH THE IMAGE AS IT WOULD WITH A FRESH HTML PAGE</p>
</body>
Hope this helps!

How do I keep my CTA image with 100% width from stretching when adjusting the height?

I am making a website and I need a CTA image.
I am using Bootstrap 4 and I have made a custom CSS to adjust how the image will look. I've put it so that it takes up the whole width of the screen, so width: 100%;
When I adjust the size of the screen, the image is responsive and also adjusts itself so that it will turn smaller and fit the whole screen. But when is on a regular big sized screen the image takes up the whole website so I want to be able to leave it as 100% width but with a smaller height. When I try adjusting the max-height it just ends up stretching the image and it is not appealing to look at. What should I do?
This is the HTML Section:
<!-- CTA Section -->
<div class="img-wrapper">
<img class="img-responsive" src="I/CTA.png">
<div class="img-overlay">
Want to see what more we have to offer?
<br><br>
<a href="coffee.html"><button class="btn btn-md btn-primary">
Click here</button></a>
</div>
</div>
<!-- /.img-wrapper -->
This is the CSS section of the code:
.img-wrapper {
position: relative;
}
.img-wrapper img {
width: 100%;
max-height: 650px;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
color: white;
font-size: 14px;
}
.img-overlay:before {
content: ' ';
display: block;
height: 60%;
}
button {
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
}
.btn-responsive {
/* matches 'btn-md' */
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
border-radius: 6px;
}
#media (max-width:760px) {
/* matches 'btn-xs' */
.btn-responsive {
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
}
You can use object-fit, though it hasn't so good browser support yet, so a solution making use of background-image might be needed (based on the browser support you require)
Here is a solution using object-fit
.img-wrapper img {
width: 100%;
max-height: 350px;
object-fit: cover;
}
Fiddle demo
Stack snippet
.img-wrapper {
position: relative;
}
.img-wrapper img {
width: 100%;
max-height: 350px;
object-fit: cover;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
color: white;
font-size: 14px;
}
.img-overlay:before {
content: ' ';
display: block;
height: 60%;
}
button {
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
}
.btn-responsive {
/* matches 'btn-md' */
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
border-radius: 6px;
}
#media (max-width:760px) {
/* matches 'btn-xs' */
.btn-responsive {
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
}
<!-- CTA Section -->
<div class="img-wrapper">
<img class="img-responsive" src="http://lorempixel.com/500/350/nature/1/">
<div class="img-overlay">
Want to see what more we have to offer?
<br><br>
<a href="coffee.html"><button class="btn btn-md btn-primary">
Click here</button></a>
</div>
</div>
Here is another using background-image.
The trick for making this work, is to keep the image in place, but with visiblity: hidden set. This will make the image wrapper size proper, and then the background image adjust without stretching.
Fiddle demo
Stack snippet
.img-wrapper {
position: relative;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.img-wrapper img {
width: 100%;
max-height: 350px;
visibility: hidden;
}
.img-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align: center;
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
color: white;
font-size: 14px;
}
.img-overlay:before {
content: ' ';
display: block;
height: 60%;
}
button {
font-family: 'Raleway', sans-serif;
letter-spacing: 2px;
}
.btn-responsive {
/* matches 'btn-md' */
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
border-radius: 6px;
}
#media (max-width:760px) {
/* matches 'btn-xs' */
.btn-responsive {
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
}
<!-- CTA Section -->
<div class="img-wrapper" style="background-image: url(http://lorempixel.com/500/350/nature/1/)">
<img class="img-responsive" src="http://lorempixel.com/500/350/nature/1/">
<div class="img-overlay">
Want to see what more we have to offer?
<br>
<br>
<a href="coffee.html">
<button class="btn btn-md btn-primary">
Click here</button>
</a>
</div>
</div>

Container with a fullscreen background image in Yii2

I'm trying to get full screen background image for this container:
<div class="header"
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2 class="text-center">test1</h2>
<p class="lead text-center">test2</p>
<p class="text-center"><a class="btn btn-lg btn-success"
href="http://localhost/"><span
class="glyphicon glyphicon-plus"></span> something</a></p>
</div>
</div>
</div>
But, the picture is showing without fullscreen view and i'm trying to get something like this:
http://ironsummitmedia.github.io/startbootstrap-business-frontpage/
and i followed every tutorial for it, but nothing is worked.!
i'm not sure if i'm using Yii2 with this bootstrapmakes any sense.
Btw, this is my site.css
html,
.my-navbar {
background-color: #ffffff;
height: 10px;
border-bottom: 1px solid #eeeeee;
}
body {
height: 100%;
background: #F5F5F5;
}
.footer {
height: 180px;
background-color: white;
border-top: 1px solid #eeeeee;
padding-top: 20px;
}
.wrap {
min-height: 100%;
height: auto;
margin: 0 auto -60px;
padding: 0 0 60px;
}
.wrap > .container {
padding: 70px 15px 20px;
}
.header {
height: 400px;
background: url('../images/header.jpg') no-repeat center center;
min-height:100%;
background-size:100px 150px;
-webkit-background-size: cover;
-moz-background-size: cover;
width: 100%;
-o-background-size: cover;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
.not-set {
color: #c55;
font-style: italic;
}
/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings', fantasy;
font-style: normal;
font-weight: normal;
line-height: 1;
padding-left: 5px;
}
a.asc:after {
content: /*"\e113"*/ "\e151";
}
a.desc:after {
content: /*"\e114"*/ "\e152";
}
.sort-numerical a.asc:after {
content: "\e153";
}
.sort-numerical a.desc:after {
content: "\e154";
}
.sort-ordinal a.asc:after {
content: "\e155";
}
.sort-ordinal a.desc:after {
content: "\e156";
}
.grid-view th {
white-space: nowrap;
}
.hint-block {
display: block;
margin-top: 5px;
color: #999;
}
.error-summary {
color: #a94442;
background: #fdf7f7;
border-left: 3px solid #eed3d7;
padding: 10px 20px;
margin: 0 0 15px 0;
}
What should i do for achieve full screen background image like this example in header?
http://ironsummitmedia.github.io/startbootstrap-business-frontpage/
Add this to the header css
position: absolute;
top: 0;
left: 0;
right: 0;
It should work now.
Could you try to putt it up as an example on Codepen?
Your div class "header" doesn't have an ending ">" which might be causing some problems.
Try with the following in the CSS where the background img is specified:
background-size:cover;
Add a other class with container class and use background image with cover option. Here i use .bimg for example.
<div class="container bimg"></div>
.bimg{
width:100%;
background:url('PATH');
}