I was trying to put some text over a picture, but I don't want to set background-image.
I've created a jsfiddle to illustrate what I did, and I use bootstrap3.
In the mobile size, it can display fine like
But if I resize the browser width, it will be broken.
html
<div class="col-xs-12 visible-sm-block visible-xs-block" style="text-align: center;">
<p class="competion_text">
This is inside the competiontion Box!
<br> Second line
<br> Third line
</p>
<img src="http://i.imgur.com/NajXOdH.png">
</div>
CSS
.competion_text {
text-align: center;
position: relative;
top: 252px;
left: 7px;
max-width: 225px;
color: #FFCF83;
font-size: 10pt;
}
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.holder {
position: relative;
width: 230px;
margin: 0 auto;
}
.competion_text {
position: absolute;
top: 180px;
left: 0;
width: 100%;
text-align: center;
color: #FFCF83;
font-size: 10pt;
z-index: 2;
}
<div class="col-xs-12 visible-sm-block visible-xs-block holder" style="text-align: center;">
<p class="competion_text">
This is inside the competiontion Box!
<br> Second line
<br> Third line
</p>
<img src="http://i.imgur.com/NajXOdH.png">
</div>
I put another class on the parent. (.holder)
Try this. Hope it helps!
Try something like this.
.competion_text {
text-align: center;
position: relative;
top: 252px;
margin: 0 auto;
max-width: 225px;
color: #FFCF83;
font-size: 10pt;
}
Here is workin jsfiddle
Try as below, Set your parent element i.e .col-xs-12 position as position:relative and child i.e. .competion_text position as position:absolute thus this aligns your text in the center of image, Now I have used CSS calc() function in top positing to align it vertically in center and that always stays there.
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.col-xs-12{
width:auto;
height:auto;
margin:auto;
text-align:center;
position:relative;
}
.col-xs-12 > .competion_text {
position: absolute;
top: calc(100% - 30%);
left: 0;
width: 100%;
height:auto;
color: #FFCF83;
font-size: 10pt;
text-align:center;
}
<div class="col-xs-12 visible-sm-block visible-xs-block">
<p class="competion_text">
This is inside the competiontion Box!
<br> Second line
<br> Third line
</p>
<img src="http://i.imgur.com/NajXOdH.png">
</div>
Related
Can seem to be able to move the image around, I need the image and the text side-by-side and it is, but I would like to be able to move the image done just a little bit so that the middle part or the image is lined up with the text. Right now it is the bottom and no matter what I do it wont move up or down, here is the html for the div and then the css
<div class="img">
<img src="/image/file/location">
<div class="imgwording">
<img src="/image/file/location" class="logoimage">
Test Text
</div>
<div class="sub">
<img src="/image/file/location" class="mail">
Test Text
</div>
<div class="imagelinks1">
Training &</br>Events
</div>
<div class="imagelinks2">
Trauma & Gender</br>Projects
</div>
<div class="imagelinks3">
Behavioral Health</br>Resources
</div>
</div>
CSS:
.imgwording {
text-decoration: none !important;
line-height: 1.28;
letter-spacing: 1.5px;
text-align: center;
font-size: 48px;
padding: 0px 60px !important;
position: absolute;
top: 65px;
width: 100%;
font-family: eb garamond,serif;
color: #fff;
display:flex;
justify-content:center;
align-items:center;
flex-direction:column;
left: -110px;
display: inline-block;
}
.logoimage {
width: 50px;
height: 100px;
}
From what I understand, you have an image and text side by side but the image is lower than it should be. What you could do is add padding-bottom to the image CSS to change its position. How many pixels you would want to move would depends on how much higher you want the image to go.
Basically doing:
.logoimage {
width: 50px;
height: 100px;
padding-bottom: 5px; /* this could be any value depending */
}
Believe after some digging I got it, just need to add
position: relative;
to the .logoimage css
Add vertical-align:middle; to your logoimage class:
.logoimage {
width: 50px;
height: 100px;
vertical-align:middle;
}
I'm trying to make one blog design, and I want to display text on image that is vertically and horizontally centered. My CSS class .featured-article have relative position. This is HTML and CSS:
<div class="featured-article">
<img src="images/Image.png" alt="Image"> <!-- This Works Perfect, I don't need to touch it anymore -->
<div class="article">
<img src="uploads/4.png" alt="Image"> <!-- Image where I need to add TextBox -->
<div class="title"> <!-- TextBox that I need to center on image -->
<span><strong>TEXT</strong> TEXT</span>
</div>
.......... Other Eelements
.......... Other Eelements
.......... Other Elements
CSS:
.featured-article { /* Container of Post */
position: relative;
margin-top: 60px;
}
.featured-article > img { /* Background Image, This Works Perfect */
position: absolute;
top: -150px;
left: 20px;
z-index: -1;
}
.featured-article > .article > img { /* Image where I need to add TextBox */
width: 100%;
}
.featured-article > .article > .title > span { /* TextBox that I need to center on image */
background-color: #9ED7D8;
padding: 25px 35px 25px 35px;
text-transform: uppercase;
max-width: 800px;
font-size: 30px;
font-weight: 300;
color: #FFF;
}
This should look like this: Example.
you can use css attribute background-image for your parent element, and inside that put your text in the child element.
after that there are many ways of positioning the child in the center of parent element...
one way would be like this:
html:
<div class="parent">
<div class="child">
your text
</div>
</div>
and css:
.parent{
background-image: url("images/Image.png");
height:...;
width:...;
}
.child{
position: absolute;
top: ....;
width: 100%;
text-align: center;
}
My header image is overlapping my text and it is very much annoying me. Another thing that is buggy is how my logo text leans right of the center of the image. If someone could help me with both that would be awesome.
Here is my code:
https://jsfiddle.net/c2bom0cc/1/
Here are my tags that are probably the most relevant to this:
#index_header {
position: block;
z-index: 0;
left: 0;
top: 0;
height: 100%;
width: 100%;
text-align: center;
vertical-align: middle;
}
#index_header img {
position: block;
float: left;
width: 100%;
height: 100%;
}
.background_title {
position: absolute;
font-family: 'Montserrat', sans-serif;
color: #FFF;
font-size: 64px;
left: 50%;
top: 50%;
}
<div class="page_container">
<div id="index_header">
<a href="#">
<img alt="slider" id="index_headerimg" src="http://www.bakeryandsnacks.com/var/plain_site/storage/images/publications/food-beverage-nutrition/bakeryandsnacks.com/regulation-safety/coles-freshly-baked-claims-false-rules-federal-court-australia/9101085-1-eng-GB/Coles-freshly-baked-claims-false-rules-Federal-Court-Australia.jpg"
/>
<p class="background_title">G.F. Bakery</p>
</a>
</div>
</div>
I let myself hold a few assumptions on your code:
First, by the full height and width of the image, I figured that you want the image as a stretched background image. So I replaced the <img> with background-image (background shorthand) in CSS Backgrounds.
From your question I see that you want the title in the center of the bakery background.
I did not get what text is overlapped by the image.
If you want text below the image, please put it in an element after <div id="index_header">...</div>, as the background is all over that <div>.
I had to add display:inline-block to .background_title class, so that the vertical-align:middle; would take effect.
I removed all the absolute positioning to handle better with all the alignments.
Absolute positioning make you manually set all the top and left, and it's really difficult to do when your code gets bigger.
Here's you new HTML:
<div class="page_container">
<div id="index_header">
<a href="#">
<p class="background_title">G.F. Bakery</p>
</a>
</div>
<p>Some other content...</p> // this text will not be overlapped by
// #index_header as long as #index_header
// isn't absolutely positioned
</div>
Here's your new CSS:
html, body{ // this is instead of having top:0 and left:0 in #index_header
padding: 0;
margin: 0;
}
.page_container {
height: 100%;
width: 100%;
}
#index_header {
height: 200px;
width: 100%;
text-align: center;
vertical-align: middle;
background: url('http://www.bakeryandsnacks.com/var/plain_site/storage/images/publications/food-beverage-nutrition/bakeryandsnacks.com/regulation-safety/coles-freshly-baked-claims-false-rules-federal-court-australia/9101085-1-eng-GB/Coles-freshly-baked-claims-false-rules-Federal-Court-Australia.jpg') no-repeat center center;
background-size: 100% 100%; // this does the stretching
}
.background_title {
display:inline-block; // this is to apply the vertical-align of parent
font-family: 'Montserrat', sans-serif;
color: #FFF;
font-size: 64px;
}
Here's a JSFiddle
Hope this helps.
If you want your text to be under your image and centered, remove the following code:
.background_title {
position: absolute;
}
Just removing the position will move your text under your image and centered.
Trying to float a box on the bottom of this image slider. Essentially the slider will have a title and caption but I also want to have a box at the bottom of the image which will pull in data using PHP.
Anyway, my problem is trying to get the white box with text to sit on the bottom of the image and stay there. If the user decreases screen size the white box should follow and stay on the bottom.
jsFiddle provided: http://jsfiddle.net/fkpe1py6/1/
<div id="homepage-slider-wrap" class="clr flexslider-container">
<div id="homepage-slider" class="flexslider">
<ul class="slides clr">
<li class="homepage-slider-slide">
<div class="homepage-slide-inner container">
<div class="homepage-slide-content">
<div class="homepage-slide-box">Float this box at the bottom of the image.</div>
</div>
<!-- .homepage-slider-content -->
</div>
<img src="http://wpexplorer-demos.com/elegant/wp-content/uploads/sites/83/2012/08/game.jpg" alt="">
</li>
</ul>
<!-- .slides -->
</div>
<!-- .flexslider -->
</div>
<!-- #homepage-slider" -->
CSS (see jsFiddle for full CSS)
.homepage-slide-box {
float:left;
bottom: 0;
margin-top: 10px;
background: #31c68b;
font-size: 1.333em;
font-weight: 600;
color: #212121;
padding: 10px;
background: #fff;
}
Thanks for your help!
I would change a couple of things:
I would place the img tag inside the .homepage-slide-content class div (this will help the div to know the height of the image).
then add some things to your CSS so that your other slide divs mimic this height.
CSS
.homepage-slider-slide{
display:block;
position:relative;
}
.homepage-slider-slide img{
display:block;
}
.homepage-slide-inner {
position: relative;
height:100%;
width:100%;
}
.homepage-slide-content {
display: block;
position: absolute;
top: 0;
left: 0;
bottom:0;
z-index: 9999;
}
.homepage-slide-box {
position:absolute;
bottom: 0;
background: #31c68b;
font-size: 1.333em;
font-weight: 600;
color: #212121;
padding: 10px;
background: #fff;
width: 350px;
}
JS FIDDLE DEMO
remove this css positioning
.homepage-slide-inner {
position: relative;
}
and add this
.homepage-slider-slide {
position: relative;
}
and change position of top: 50px to .homepage-slide-content {bottom : 0}
jFiddle
So I've been working on a page with text and an image. However, I can't find a way to put the image between the text. either it stays on the top left, or it only centers horizontally. here is the code that is of importance:
<style>
body {
margin: 0;
background-image: url("rainbowbg.png");
}
div #hype {
margin-left: auto;
margin-right: auto;
display: block;
positon: relative;
}
#hypetop {
position: fixed;
top: 0;
width: 100%;
}
#hypebot {
position: fixed;
bottom: 0;
width: 100%;
}
.hypetext {
font-family: Impact, Charcoal, sans-serif;
font-size: 64px;
text-align: center;
}
</style>
<body>
<div>
<h1 class="hypetext" id="hypetop">DIRE</h1>
<img id="hype" src="DIREHYPE.png" width="224" height="224">
<h1 class="hypetext" id="hypebot">HYPPPPPPPPPPPE</h1>
</div>
</body>
If anyone knows how I could get the image centered between the text, that would be great.
You can use this responsive css code. It may be help for you. Try it.I can change only position:fixed to position:relative.
Live Working Demo
HTML Code:
<div>
<h1 class="hypetext" id="hypetop">DIRE</h1>
<img id="hype" src="http://s30.postimg.org/qnju89rkx/banner.png" width="224" height="224"/>
<h1 class="hypetext" id="hypebot">HYPPPPPPPPPPPE</h1>
</div>
CSS Code:
body {
margin: 0;
background-image: url("rainbowbg.png");
}
div #hype {
margin:auto;
display: block;
position: relative;
margin-top:50px;
}
#hypetop {
position: relative;
top: 0;
width: 100%;
}
#hypebot {
position:relative;
bottom: 0;
width: 100%;
}
.hypetext {
font-family: Impact, Charcoal, sans-serif;
font-size: 64px;
text-align: center;
}
Result:
Remove position:fixed; from hypetop and hypebot. This caused these elements to have fixed positions and not relative to the image.
you have to imagine them as blocks first. From what I get .. you need 3 blocks in the horizontal order: paragraph | image | paragraph , which gives us the following structure:
<p></p><img></img><p></p>
what you are missing is.. that you need to use the span tag instead fo a tag to make them not break. Which is opposite of making the page responsive (using )
simply put them like this:
<span>
<span id="test"><h1></h1></span>
<img src="" width="200px" height="200px" />
<span id="test"><h1></h1></span>
</span>
#test {
position: relative;
height: 200px;
width: 200px;
text-align: center;
display: block;
}
giving the above css rules... puts the text into a invisible/transparent block.. because we are not declaring any backround-color value. thus all 3 blocks become equal size.. 200px by 200px .. side-by-side in one line..