Styling text on image
up vote
0
down vote
favorite
I have an image and text on it in two different divs with a background color,
text in one div is long and in the second div is short but the width of both divs are equal that is I don't want.
Here is my code:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>All I need is like in the picture attached desired output:
.
I tried many tricks but not understand how to do this.
html css
add a comment |
up vote
0
down vote
favorite
I have an image and text on it in two different divs with a background color,
text in one div is long and in the second div is short but the width of both divs are equal that is I don't want.
Here is my code:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>All I need is like in the picture attached desired output:
.
I tried many tricks but not understand how to do this.
html css
.lower-text display:inline-block;
– Stender
2 days ago
oh man thanks buddy. it worked for me!
– Just Code
2 days ago
No problem - might as well close this question since it is doubtful that it will be helpfull for future users ;)
– Stender
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an image and text on it in two different divs with a background color,
text in one div is long and in the second div is short but the width of both divs are equal that is I don't want.
Here is my code:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>All I need is like in the picture attached desired output:
.
I tried many tricks but not understand how to do this.
html css
I have an image and text on it in two different divs with a background color,
text in one div is long and in the second div is short but the width of both divs are equal that is I don't want.
Here is my code:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>All I need is like in the picture attached desired output:
.
I tried many tricks but not understand how to do this.
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>html css
html css
edited 2 days ago
Suraj Rao
22k75467
22k75467
asked 2 days ago
Just Code
92
92
.lower-text display:inline-block;
– Stender
2 days ago
oh man thanks buddy. it worked for me!
– Just Code
2 days ago
No problem - might as well close this question since it is doubtful that it will be helpfull for future users ;)
– Stender
2 days ago
add a comment |
.lower-text display:inline-block;
– Stender
2 days ago
oh man thanks buddy. it worked for me!
– Just Code
2 days ago
No problem - might as well close this question since it is doubtful that it will be helpfull for future users ;)
– Stender
2 days ago
.lower-text display:inline-block;– Stender
2 days ago
.lower-text display:inline-block;– Stender
2 days ago
oh man thanks buddy. it worked for me!
– Just Code
2 days ago
oh man thanks buddy. it worked for me!
– Just Code
2 days ago
No problem - might as well close this question since it is doubtful that it will be helpfull for future users ;)
– Stender
2 days ago
No problem - might as well close this question since it is doubtful that it will be helpfull for future users ;)
– Stender
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Make the display of the second div inline-block so it doesn't span 100% width.
Heres an example:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Make the display of the second div inline-block so it doesn't span 100% width.
Heres an example:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>add a comment |
up vote
0
down vote
accepted
Make the display of the second div inline-block so it doesn't span 100% width.
Heres an example:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Make the display of the second div inline-block so it doesn't span 100% width.
Heres an example:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>Make the display of the second div inline-block so it doesn't span 100% width.
Heres an example:
.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>.banner
position: relative;
.banner img
width: 100%;
.image-text
position: absolute;
top: 40%;
left: 8%;
.image-text h2
font-size: 22px;
font-weight: bolder;
color: #fff;
margin: 0px;
.upper-text
background: #2b96c3;
padding: 5px 10px;
.lower-text
background: #0d729c;
padding: 5px 10px;
display: inline-block;
<section>
<div class="banner">
<img src="https://i.imgur.com/xTeFbiv.jpg">
<div class="image-text">
<div class="upper-text">
<h2>Excellent Successfull</h2>
</div>
<div class="lower-text">
<h2>Sustainable</h2>
</div>
</div>
</div>
</section>answered 2 days ago
Alex Gray
35627
35627
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225230%2fstyling-text-on-image%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
.lower-text display:inline-block;– Stender
2 days ago
oh man thanks buddy. it worked for me!
– Just Code
2 days ago
No problem - might as well close this question since it is doubtful that it will be helpfull for future users ;)
– Stender
2 days ago