Can't see any background image - in IE 7 and IE 8 - html

For some reason, iE8 and IE7 are not behaving like other browsers, and the relative position element background image, doesn't appear.
Any suggestions please?
The HTML
<div id="container1">
<div class="main-column">
<h2>Hello tittle 1</h2>
<div class="text-column">
<p>I'm on column 1 and I like it</p>
<p>I'm on column 1 as well</p>
</div>
</div>
<div class="main-column">
<h2>Hello tittle 2</h2>
<div class="text-column">
<p>I'm on column 2 and I like it</p>
<p>I'm on column 2 as well</p>
</div>
</div>
<div class="main-column">
<h2>Hello tittle 3</h2>
<div class="text-column">
<p>I'm on column 3 and I like it</p>
<p>I'm on column 3 as well</p>
</div>
</div>
</div>
Notes:
a) Absolute position instead of relative will ruin the all layout.
b) I have a space on my background declaration so it's not a space issue.
Try I:
The same markup, but now with absolute position:
#container1 {
background-color: red;
text-align: center;
}
.main-column {
display: inline-block;
}
.main-column h2 {
width: 220px;
height: 235px;
padding-top: 110px;
position: absolute; /* <<-- Changed */
background: url('http://s24.postimg.org/ossqwb7hh/carica_Kairos.png') no-repeat center top;
margin: 0 auto;
}
.text-column {
width: 220px; /* <<-- Make it equal to the h2 */
height: 300px;
background-color: yellow;
margin: 120px auto 0 auto;
padding-top: 270px; /* <<-- Adjust */
}
.text-column p {
padding: 0 50px;
}
same issue. IE8 and IE7 not displaying images. :(

I'm not quite sure what you're looking to do, but since the h2 is a block item, it might not obey your height/width CSS. I would float or absolute position it.

EDIT: Here is a working workaround, please test it on youtr machine since I'm using IE8 emulator. JSFiddle
HTML
<div id="container1">
<div class="main-column">
<div class="h2"><span>Title 1</span><img src="http://s24.postimg.org/ossqwb7hh/carica_Kairos.png" width="230" height="243" /></div>
<div class="text-column">
<p>I'm on column 1 and I like it</p>
<p>I'm on column 1 as well</p>
</div>
</div><br>
<div class="main-column">
<div class="h2"><span>Title 1</span><img src="http://s24.postimg.org/ossqwb7hh/carica_Kairos.png" width="230" height="243" /></div>
<div class="text-column">
<p>I'm on column 1 and I like it</p>
<p>I'm on column 1 as well</p>
</div>
</div><br>
<div class="main-column">
<div class="h2"><span>Title 1</span><img src="http://s24.postimg.org/ossqwb7hh/carica_Kairos.png" width="230" height="243" /></div>
<div class="text-column">
<p>I'm on column 1 and I like it</p>
<p>I'm on column 1 as well</p>
</div> </div>
</div>
CSS
#container1 {
background-color: red;
text-align: center;
}
.main-column {
display: inline-block;
}
.main-column .h2 {
width: 220px;
height: 244px;
padding-top: 110px;
position: relative;
/*background: url('http://s24.postimg.org/ossqwb7hh/carica_Kairos.png') no-repeat center top;*/
}
.main-column .h2 span{
z-index: 2;
position: absolute;
text-align: center;
line-height: 243px;
margin-top: -110px;
left: 0;
width:100%;
font-weight: bold;
font-size: large;
}
.main-column .h2 img {
position: absolute;
top: 0;
left: -4px;
z-index: 0;
}
.text-column {
width: 220px;
height: 300px;
background-color: yellow;
margin: -223px auto 0 auto;
padding-top: 220px;
}
.text-column p {
padding: 0 50px;
}
OLD answer below
It seems you are using <h2> like a block when its a header element. You should try these tips for now:
Explicitly declare display: block; on that element.
Explicitly declare them all as position: relative;
Change the <h2> tag to a <div>

Related

Aligning text on a box

I have this flip box which looks like this
When I hover on it, it would turn around and would look like this.
I want to know, how do I move the text to the right only, I tried putting text-align: right; on my css but it didn't work. Am I doing it wrong?
Here's my CSS and HTML:
.box9 {
background-color: #4C586F;
width: 250px;
height: 150px;
margin: 0 auto;
padding: 45px;
}
.box10 {
background-image: url("../img/commended/erwin.png");
background-size: 50%;
background-repeat: no-repeat;
width: 250px;
height: 150px;
margin: 0 auto;
padding: 45px;
}
<div class="col_third">
<div class="hover panel">
<div class="front">
<div class="box9">
<p style="font-size:180%; color: white">Kudos!</p>
</div>
</div>
<div class="back">
<div class="box10">
<p style="font-size:180%; color: black">sdasdsadas</p>
</div>
</div>
</div>
</div>
I would do it like this, setting text-align: right in the back view and to center in the front view, vertical centering of the p tag and also changing some other settings (no padding [therefore changed width and height settings] and some other details):
.box9 {
background-color: #4C586F;
width: 340px;
height: 240px;
margin: 0 auto;
text-align: center;
}
.box10 {
background-image: url(http://placehold.it/150x250/);
background-size: auto 100%;
background-repeat: no-repeat;
width: 340px;
height: 240px;
margin: 0 auto;
text-align: right;
}
.box9 p,
.box10 p {
margin: 0;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.box10 p {
padding-right: 20px;
}
<div class="col_third">
<div class="hover panel">
<div class="front">
<div class="box9">
<p style="font-size:180%; color: white">Kudos!</p>
</div>
</div>
<div class="back">
<div class="box10">
<p style="font-size:180%; color: black">sdasdsadas</p>
</div>
</div>
</div>
</div>

How To place Both Logo and text in the Same Line?

what is the HTML with CSS Code to align have logo and text in the same line...that it must look as shown in the below pattern..
HTML:
<div class="top_left">
<div class="header">
<img src="https://b.fastcompany.net/multisite_files/fastcompany/imagecache/inline-small/inline/2015/09/3050613-inline-i-2-googles-new-logo-copy.png" alt="logo"/> <br/>
</div>
<h2 id="site-title"><a>GOOGLE</a>
<div id="site-description">SEARCH ENGINE </div>
</h2>
</div>
You can use the following html/css combo:
/* CSS */
.container-div {
position: fixed;
top: 0px;
left: 0px;
width: 250px;
height: 150px;
}
.img-div {
display: inline-block;
position: relative;
width: 45%;
height: 100%;
overflow: hidden;
}
.img-div img {
position: absolute;
top: 0px;
left: 5%;
width: 90%;
height: 50%;
border: 1px solid red;
}
.img-placeholder {
position: absolute;
top: 7.5%;
left: 15%;
}
.text-div {
display: inline-block;
position: relative;
width: 50%;
height: 100%;
border: 1px solid green;
overflow: auto;
}
<!-- HTML -->
<div class="container-div">
<div class="img-div">
<img />
<p class="img-placeholder">
Image Goes Here
</p>
</div>
<div class="text-div">
<h2>
Texty-text
</h2>
<p>
Sub-texty-text
</p>
</div>
</div>
Use this code
<p><img src="https://cdn.pixabay.com/photo/2016/12/27/21/03/lone-tree-1934897_960_720.jpg" alt="imag" style="height: 50px;width: 50px;"><span>kiran</span></p>
hello try to make a container for the logo and the text and a few div with a float that would do the job if i am right
like this
<div class="name of class you made" //give jut a with>
<div class="logo" //put float in this with a with>logo</div><div class="tekst" //put float in this with a with>tekst</div>
</div>
i am not sure but this would help
You can either use (on the h4 elements, as they are block by default)
display: inline-block;
Or you can float the elements to the left/rght
float: left;
Just don't forget to clear the floats after
clear: left;
Try something like this
<div class="container">
<div id="logo">
<img src="http://placehold.it/150x100">
</div>
<div id="text">
<h2>Hello</h2>
<h3>World</h3>
</div>
</div>
CSS:
.container > div {
display: inline-block;
padding: 5px;
}
#logo, #text {
float: left;
}
Here's the fiddle

align the fixed position image on center for all devices

I have a fixed header and a image below the header.
The image has a property position: fixed.
Now for some devices the image is not in the center as It should be.
Here's the fiddle for it.
The left side has more spaces than the right hand side.
Also above the image, I want to add a p tag which is not showing up for some reason.
Please let me know what's wrong here.
<div class="content-wrapper new-class">
<div class="container">
<div class="row">
<div class="col-xs-12 ">
<div class="center-logo description">
<img src="http://i.imgur.com/ECTLTbK.png" alt="" class="img-responsive">
<P class="step1description" See price</p>
</div>
</div>
</div>
</div>
</div>
Checkout this solution:
body, html {
margin:0;
padding:0;
}
.content-wrapper {
position: relative;
overflow: hidden;
width: 100%;
background-color: #333230;
}
.content-wrapper .center-logo {
position: fixed;
width: 100%;
top: 125px;
left:0;
text-align: center;
margin: 5px 0 15px;
z-index: 1001;
background-color: #333230;
}
.content-wrapper .center-logo img {
margin: 0 auto;
}
.center-logo p.step1description {
position: relative;
top: -30px;
width: 220px;
text-align: center;
color: #fff;
font-size: 12px;
margin: 0 auto;
}
.description {
margin:30px 0 30px 0 !important;
}
.content-wrapper .content {
text-align: center;
width: 100%;
}
.new-class{
padding-bottom: 134px;
top: 134px;
}
<div class="content-wrapper new-class">
<div class="container">
<div class="row">
<div class="col-xs-12 ">
<div class="center-logo description">
<img src="http://i.imgur.com/ECTLTbK.png" alt="" class="img-responsive">
<p class="step1description"> See price</p>
</div>
</div>
</div>
</div>
</div>
You have some typos on html and css! - Here you can find a working fiddle: http://jsfiddle.net/sebastianbrosch/cxumhp9k/1/
Add left:0 on .content-wrapper .center-logo
.content-wrapper .center-logo { left:0;}

Why does a parent div resize to it's child elements?

I have 3 div boxes which were perfectly aligned and centered, and then when I added text inside the divs, the parent div would stretch and resize to what was inside. I tried using resize: none on the child and parent elements, but that didn't do anything. Also tried using position:absolute; and relative.
HTML
<div class="boxes-parent">
<div class="left-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">About</h1>
<p class="blue-box-text">I used to be better at CSS and HTML. Sorry!</p>
</div>
</div>
<div class="center-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Info</h1>
<p class="blue-box-text">Info info info.</p>
</div>
</div>
<div class="right-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Contact</h1>
<p class="blue-box-text">Phone: (888) 888-8888</p>
</div>
</div>
</div>
CSS
.boxes-parent {
margin: 0px auto;
text-align: center;
}
.left-box, .center-box, .right-box {
padding-top: 10px;
padding-left: 2%;
padding-right: 2%;
display: inline-block;
position: relative;
min-width: 25%;
}
.blue-boxes {
background-color: #3498db;
height: 250px;
position: absolute;
resize: none;
}
.blue-box-header-text {
padding-top: 20px;
font-size: 26px;
color: #fff;
}
.blue-box-text {
resize: none;
max-width: 500px;
position: relative;
display: inline;
}
Result: https://jsfiddle.net/0wvyaqbo/
Also, my questions sometimes get downvoted. Have any advice on how I can better format this question? Trying to make it applicable for others. Thanks for all the help!
There are a couple things going on:
First, you have your .right, .center, .left divs set to inline-block. By default, they will always be the width of the content, because of inline-block. You need to set them to block. Also, .blue-boxes should be set to relative positioning, not absolute.
Here's updated CSS:
.boxes-parent {
margin: 0px auto;
text-align: center;
}
.left-box, .center-box, .right-box {
padding-top: 10px;
padding-left: 2%;
padding-right: 2%;
display: block;
position: relative;
width: 25%;
float:left;
}
.blue-boxes {
background-color: #3498db;
height: 250px;
position: relative;
}
.blue-box-header-text {
padding-top: 20px;
font-size: 26px;
color: #fff;
}
.blue-box-text {
resize: none;
max-width: 500px;
position: relative;
display: inline;
}
And the updated fiddle:
https://jsfiddle.net/0wvyaqbo/1/
Another way to do this would be to use flexbox. Simply add display: flex and justify-content: center to .boxes-parent and change min-width to simply width for .left-box, .center-box, and .right-box. Resulting code looks like this:
.boxes-parent {
margin: 0 auto;
text-align: center;
display: flex;
justify-content: center;
}
.left-box,
.center-box,
.right-box {
width: 25%;
padding: 10px 2% 0;
}
.blue-boxes {
background-color: #3498db;
height: 250px;
}
.blue-box-header-text {
padding-top: 20px;
font-size: 26px;
color: #fff;
}
<div class="boxes-parent">
<div class="left-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">About</h1>
<p class="blue-box-text">I used to be better at CSS and HTML. Sorry!</p>
</div>
</div>
<div class="center-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Info</h1>
<p class="blue-box-text">Info info info.</p>
</div>
</div>
<div class="right-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Contact</h1>
<p class="blue-box-text">Phone: (888) 888-8888</p>
</div>
</div>
</div>
Alternatively, you could use flex: 1 1 25% for .left-box, .center-box, and .right-box. This forces them to grow and shrink with each other.
.boxes-parent {
margin: 0 auto;
text-align: center;
display: flex;
justify-content: center;
}
.left-box, .center-box, .right-box {
flex: 1 1 25%;
padding: 10px 2% 0;
}
.blue-boxes {
background-color: #3498db;
height: 250px;
}
.blue-box-header-text {
padding-top: 20px;
font-size: 26px;
color: #fff;
}
<div class="boxes-parent">
<div class="left-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">About</h1>
<p class="blue-box-text">I used to be better at CSS and HTML. Sorry!</p>
</div>
</div>
<div class="center-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Info</h1>
<p class="blue-box-text">Info info info.</p>
</div>
</div>
<div class="right-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Contact</h1>
<p class="blue-box-text">Phone: (888) 888-8888</p>
</div>
</div>
</div>
For more info on flexbox, css-tricks has a good reference sheet. Here's the support tables as well.
Parent elements likes divs are flexible by default and will resize to contain whatever you put in them (height) or whatever their parent element(s)/the browser is doing (width) unless you specify their dimensions. Use CSS width and height or max-width and max-height on the parent to limit its growth.
Generally, a flexible parent is preferred (see: responsive design), as some users may choose to modify the font your site is using, increase the font size to improve visibility, or view the site from a different device, and these actions can change the relative size of your content.
More info: http://www.w3schools.com/cssref/pr_dim_height.asp
You used min-width, and expected adding content wouldn't cause them to grow? Just use width.
Setting .blue-boxes { position: absolute; } caused those to shrink to the size of the content. You could add width: 100%;.
Since using absolute positioning can mess up layout, a solution that avoids it would be nice. When you remove the absolute positioning, the blue boxes are no longer aligned vertically. Set vertical-align: top; to fix that.
.boxes-parent {
margin: 0px auto;
text-align: center;
}
.left-box, .center-box, .right-box {
padding-top: 10px;
padding-left: 2%;
padding-right: 2%;
display: inline-block;
width: 25%;
vertical-align: top;
}
.blue-boxes {
background-color: #3498db;
height: 250px;
}
.blue-box-header-text {
padding-top: 20px;
font-size: 26px;
color: #fff;
}
.blue-box-text {
display: inline;
}
<div class="boxes-parent">
<div class="left-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">About</h1>
<p class="blue-box-text">I used to be better at CSS and HTML. Sorry!</p>
</div>
</div>
<div class="center-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Info</h1>
<p class="blue-box-text">Info info info.</p>
</div>
</div>
<div class="right-box">
<div class="blue-boxes">
<h1 class="blue-box-header-text">Contact</h1>
<p class="blue-box-text">Phone: (888) 888-8888</p>
</div>
</div>
</div>

Two boxes, side by side, 50% each, but both are slighty longer and not on same line?

I'm trying to get two side-by-side boxes to take up the entire width of the screen. However, when setting the width at 50%, each of the boxes wants to extend about 10px wider than 50%. What am I doing wrong?
#sides {
padding-top: 40px;
padding-bottom: 40px;
background-color: white;
}
#leftside {
width: 50%;
background-color: grey;
padding: 20px;
margin: 0px;
position: relative;
}
#rightside {
width: 50%;
display: inline-table;
background-color: #018DCA;
float: left;
padding: 20px;
margin-left: 50%;
position: relative;
}
.
.
.
<div id="sides">
<div id="leftside">
<h1>text</h1>
<p>
<h2>text</h2>
<br>
</div>
<div id="rightside">
<h1>text</h1>
<p>
<h2>text</h2>
<br>
</div>
</div>
Both sides need to be floated and make sure that you're using box-sizing: border-box; to ensure that the width is 50% regardless of padding and border size.
I realise that your question has already been solved, but another option to TylerH's solution would be to use flex. Like so:
#sides {
display:flex;
padding: 40px 0px;
background-color: white;
}
.side {
flex:1;
padding: 20px;
margin: 0;
}
#left{background-color: grey;}
#right{background-color: #018DCA;}
<div id="sides">
<div class="side" id="left">
<h1>text</h1>
<h2>text</h2>
</div>
<div class="side" id="right">
<h1>text</h1>
<h2>text</h2>
</div>
</div>
As TylerH rightly pointed out, this does require more modern browsers. Take a look at this website for more information on compatibility.
You don't need to use float (in fact it's not really the right tool for overall document layout; it's more for breaking up text with images without destroying the document flow).
You can achieve this with less CSS by using display: inline-block; and commenting out the white-space between your left and right <div>s. JSFiddle
html, body {
margin: 0;
}
#sides {
padding-top: 40px;
padding-bottom: 40px;
background-color: white;
}
#leftside {
width: 50%;
background-color: grey;
padding: 20px 0;
display: inline-block;
}
#rightside {
width: 50%;
display: inline-block;
background-color: #018DCA;
padding: 20px 0;
}
<div id="sides">
<div id="leftside">
<h1>text</h1>
<p>
<h2>text</h2>
<br>
</div><!--
--><div id="rightside">
<h1>text</h1>
<p>
<h2>text</h2>
<br>
</div>
</div>
Use display:inline-blockAdd font-size:0 to the parent div,this must do. Also try adding vertical-align:top to right div
#sides {
padding-top: 40px;
padding-bottom: 40px;
background-color: white;
}
#leftside {
width: 47%;
background-color: grey;
float: left;
padding:5px;
}
#rightside {
width: 47%;
background-color: #018DCA;
float: right;
padding:5px;
}
<div id="sides">
<div id="leftside">
<h1>text</h1>
<p>
<h2>text</h2>
<br>
</div>
<div id="rightside">
<h1>text</h1>
<p>
<h2>text</h2>
<br>
</div>
</div>