Safari CSS positioning rules seem mutually exclusive to that of other browsers - html

I have some CSS that looks fine in Chrome and Firefox, but is turning up a specific problem in Safari. The three divs/ul items are aligning properly in Chrome and Firefox, but are stacking directly on top of each other in Safari. To make it look right in Sf, I can make the left margin progressively larger between the three, but the result in FF and Chrome is that the divs go way off the page. I have tried a few hacks including this one:
#media screen and (-webkit-min-device-pixel-ratio:0){}
This didn't change anything. So here's the relevant HTML:
<ul id="nav">
<li class="nav_item"><div id= "work"> </div></li>
<li class="nav_item"><div id="about"> </div></li>
<li class="nav_item"><div id="contact"> </div></li>
</ul>
...And the CSS:
#work{ height: 50px;
width: 68px;
font-family: Helvetica, Arial, sans-serif;
font-size: 24px;
background-color: none;
background-image: url(work_1.png);
background-repeat: no-repeat;
background-size: 120%;
position: fixed;
text-align: center;
z-index: 201;
padding: 0px 0px 0px 0px;
margin: 1px 1px 1px 40px;
display: block;
clear: both;
float:right;}
#about{ height: 50px;
width: 68px;
font-family: Helvetica, Arial, sans-serif;
font-size: 24px;
background-color: none;
background-image: url(about.png);
background-repeat: no-repeat;
background-size: 120%;
position: fixed;
text-align: center;
z-index: 201;
padding: 0px 0px 0px 0px;
margin: 1px 1px 1px 40px;
display: block;
clear: both;
float: right;}
#contact{ height: 50px;
width: 84px;
font-family: Helvetica, Arial, sans-serif;
font-size: 24px;
background-color: none;
background-image: url(contact.png);
background-repeat: no-repeat;
background-size: 100%;
position: fixed;
text-align: center;
z-index: 200;
padding: 0px 0px 0px 0px;
margin: 1px 1px 1px 40px;
display: block;
clear: both;
float:right;}
#nav {
padding: 0px;
display:inline;
list-style-type:none;
margin: 30px 0px 0px 700px;
position:fixed;
width:600px;
}
.nav_item {
display:inline !important;
position:relative !important;
margin: 5px 5px 5px 150px;
width:100px;
display: inline !important;
}

Related

Weird css/html gap when going to chrome mobile device view

I have a weird gap that creates scroll on x axis when I switch from normal pc browser view to mobile view with F12 on google chrome. The gap exists on mobile view until I reload the page and then it's gone.
You can see it on the picture below.
<div id="search">
</div>
<div id="search-content">
<div class="search-item"></div><br>
</div>
CSS:
html{
width: 100%;
font-family: 'PT Sans', sans-serif;
}
#header{
color:white;
background: #0198E1;
height: 65px;
}
#header-text{
margin: 0px;
height: 65px;
text-align: center;
padding-top: 17px;
font-size: 25px;
}
#search{
width: 100%;
height: 180px;
background: #2a3849;
}
#search-content{
background:#f4f4f4;
width: 100%;
text-align: center;
padding-bottom: 50px;
padding-top: 40px;
}
.search-item{
background: #ffffff;
height: 200px;
width: 1000px;
margin-top: 10px;
display: inline-block;
-webkit-box-shadow: 1px 2px 9px 0px rgba(0,0,0,0.31);
-moz-box-shadow: 1px 2px 9px 0px rgba(0,0,0,0.31);
box-shadow: 1px 2px 9px 0px rgba(0,0,0,0.31);
}
#content{
}
#media screen and (max-width: 1100px) {
.search-item{
width: 95%;
height: 180px;
}
}

Center content on any browser

I have the following CSS. It needs to be centered on any screen but currently it is only centered on a certain kind of screen:
#import url(http://fonts.googleapis.com/css?family=Roboto+Condensed);
html{
/* font-family: 'Roboto Condensed', sans-serif;*/
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 20;
}
#description{
position: absolute;
top: 200px;
left: 400px;
}
#content{
margin: 0 auto;
height: 100%;
width: 100%;
text-align: center;
line-height: 100%;
display:table-cell;
vertical-align: middle;
}
h1{
color:#4A4A4A;
margin: 0 auto;
text-align: center;
}
h1:hover{
color:#4A4A4A;
}
h2{
color:#4A4A4A;
margin: 0 auto;
text-align: center;
}
h2:hover{
color:#4A4A4A;
}
a{
color:black;
text-decoration: none;
margin: 0px auto;
width: 400px;
}
.circular{
display: block;
margin-left: auto;
margin-right: auto;
width: 150px;
height: 150px;
border-radius: 75px;
-webkit-border-radius: 75px;
-moz-border-radius: 75px;
background: url(./images/profile_picture.jpg) no-repeat;
box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-webkit-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
-moz-box-shadow: 0 0 8px rgba(0, 0, 0, .8);
}
ul{
padding: 0;
text-align:center;
padding-top: 5
}
ul a img {
padding-top: 20px;
}
li{
list-style: none;
text-align: center;
font-size: 30px;
display: inline-block;
margin-right: 10px;
}
#back{
position:absolute;
top:0;
left:0;
bottom:0;
right: 0;
z-index: -99999;
background-color: #f7f7f7;
background-size: cover;
background-position: center center;
opacity: .2;
}
Currently my website only centers on a 4x3 screen. How can I adjust my CSS to center on any size screen?
Edit: Same question is here with HTML.
You have not posted your HTML code (dont know why (?))!
Well the trick to center an element with CSS is to give the element a left and right margin value of auto
#wrapper
{
width: 500px;
margin-left: auto;
margin-right: auto;
}
This is also similar to margin:0 auto which is widely used !
Wrap your content using a <div id="wrapper">...</div> and set a width !
To center an image, add display:block to it since by default the images have display:inline property.
#myImage
{
width: 50px;
height: 50px;
margin-left: auto;
margin-right: auto;
display: block;
}
Update: The answer from Magesh Kumaar is better, but this still works.
Without seeing the code on your page, it is a little difficult. But to center a DIV on any screen you should use the following code:
#divID {
position: absolute;
width:400px;
left:50%;
margin-left:-200px; /*This should always be 50% of your width*/
}
You should then wrap the rest of your website in the DIV.
<div id="divID">
YOUR WEBSITES CONTENT GOES HERE
</div>
Wrap your content, set width, and add margin: 0 auto to the wrap's css
<div id="body">
<div id="wrap">
<div id="center">Center</div>
</div>
</div>
#wrap {
margin:0 auto;
width:50%;
}
Fiddle
Firstly define the Div id in HTML as:
<div id="page">
website content
</div>
Then in CSS: set width, and add margin: 0 #page {
margin:0 auto;
width:50%;
}

Align text vertically center of h2 tag with a background

I have a h2 tag that has a background image as an icon. I want to align the text vertically within the h2 tag but it doesn't work. I have tried using the display: table-cell; but that hasn't worked either. The text may also crossover onto two lines.
HTML:
<ul class="FeatureRow">
<li><span><h2 class="SpeechBg">Need some help?</h2><p>Feel free to get in contact with us</p></span></li>
<li><span><h2 class="PinBg">Great locations!</h2></span></li>
<li><span><h2 class="ViewBg">View our apartments</h2></span></li>
</ul>
CSS:
a {
color: #2b6893;
text-decoration: none;
}
.FeatureRow{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
.FeatureRow li{
float: left;
padding: 10px;
margin: 10px;
height: auto;
-webkit-box-shadow: 0px 4px 8px #f5f5f5;
-moz-box-shadow: 0px 4px 8px #f5f5f5;
box-shadow: 0px 4px 8px #f5f5f5;
background-color: #fdfdfd;
background-image: -moz-linear-gradient(top,#fbfbfb,#ffffff);
background-image: -webkit-gradient(linear,0 0,0 100%,from(#fbfbfb),to(#ffffff));
background-image: -webkit-linear-gradient(top,#fbfbfb,#ffffff);
background-image: -o-linear-gradient(top,#fbfbfb,#ffffff);
background-image: linear-gradient(to bottom,#fbfbfb,#ffffff);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbfbfb',endColorstr='#ffffffff',GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled= false);
}
.FeatureRow span{
display: block;
width: 260px;
}
.FeatureRow h2{
background-repeat: no-repeat;
padding-left: 65px;
font-size: 22px;
height: auto;
min-height: 60px;
color: #3F92ED;
}
.SpeechBg{
background-image: url(http://joshblease.co.uk/Apartments/images/icons/speech.png);
}
.PinBg{
background-image: url(http://joshblease.co.uk/Apartments/images/icons/pin.png);
}
.ViewBg{
background-image: url(http://joshblease.co.uk/Apartments/images/icons/view.png);
}
JSFiddle Example: http://jsfiddle.net/YPnTp/
In .SpeechBg, .PinBg, and .ViewBg, add line-height: ##px;, where ## is the height (in px) of the background images.
Change your
.FeatureRow h2 , add line-height
css as follows
.FeatureRow h2{
background-repeat: no-repeat;
padding-left: 65px;
font-size: 22px;
height: auto;
min-height: 60px;
color: #3F92ED;
line-height:2.5em;
}

Chrome 1px line bug

I am making one fan-site and have very stupid bug on news bar. When I zoom the page, 1px line appears.
This is the code:
<div class="velikibar">
<div id="velikibar_h">
<div id="naslovbar"><?=$naslov?></div>
</div>
<div id="velikibar_b">
<div class="paddingvelikibar">
<?=$sadrzaj?>
</div>
</div>
<div id="velikibar_f">
<div id="fblikedugme"><?=$vreme?><br /><div class="fb-like" data-href="http://********.**/article.php?id=<?=$id?>" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div></div>
<div id="komentarbarbox">Komentari (<?=$brkomentara?>)</div>
</div>
And this is the CSS (http://tny.cz/d9fb11db):
.velikibar
{
background-color:transparent;
width: 652px;
}
#velikibar_h
{
background-image:url('slike/velikibar_h.png');
background-repeat: no-repeat;
width: 652px;
height: 109px;
padding: 0;
margin: 0;
}
#velikibar_b
{
background-image:url('slike/velikibar_b.png');
background-repeat: repeat-y;
width: 652px;
min-height: 30px;
padding: 0;
margin: 0;
}
#velikibar_f
{
background-image:url('slike/velikibar_f.png');
background-repeat: no-repeat;
width: 652px;
height: 112px;
padding: 0;
margin: 0;
}
#velikibar_f2
{
background-image:url('slike/velikibar_f2.png');
background-repeat: no-repeat;
width: 652px;
height: 112px;
padding: 0;
margin: 0;
}
.paddingvelikibar
{
padding: 5px 35px 5px 30px;
text-align:justify;
color: #fff5f9;
}
#fblikedugme
{
position: absolute;
margin-left: 35px;
margin-top: 40px;
color:#fff5f9;
line-height: 20px;
}
#komentarbarbox
{
position: absolute;
margin-left: 425px;
margin-top: 65px;
}
#komentarbarbox a, #komentarbarbox a:link, #komentarbarbox a:visited
{
font-size: 14px;
font-weight: bold;
text-shadow: 0 1px 0 #6f1c3f;
color: #fdd2e4;
text-decoration:none;
}
#komentarbarbox a:hover, #komentarbarbox a:focus
{
color: #d61566;
text-decoration:none;
}
#naslovbar
{
font: 23px/1.4em arial, helvetica;
color: #e1aec4;
padding-top: 50px;
padding-left: 35px;
text-shadow: #FCFCFC 0px 1px 0px;
}
.paddingvelikibar img
{
background-color: #fff2f7;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
behavior: url("skripte/ie-css3.htc");
padding: 4px;
}
Please help me how to fix this. Thanks in advance
This appears to be a browser bug.
For example, an element which is 5px wide, viewed on 1.5 zoom would be 7.5px wide, but the browser has to round it to full pxls so something like this can happen.
To make sure it doesnt happen you can make the elements overlap, or in your case, best would be not to split the pink background image in 2 elements, but have a single element carry the whole image.
Chrome doesnt use font-resize as zoom option, so it is very unlikely that this is caused by a particullar line of css.

horizontal css navigation problem

Hello not sure why but having some problem with a navigation. It seems to be overflowing and if I fix it in one browser it fails in the other. So I am not sure what is wrong with it. Recently the CSS broke and the entire menu is beyond messed up.
any ways heres is the site http://www.otaku-plus.com/triton
EDITED: updated code bit: http://jsfiddle.net/yukimura/hqyY2/embedded/result/
here is the css bit for the menu
#dropfish {
background-attachment: scroll;
background-clip: border-box;
background: #111111 url("images/top-bar-bg.png");
background-origin: padding-box;
background-position: 0% 0%;
background-repeat: repeat-x;
background-size: auto;
color: #000000;
left: 0px;
padding-left: 2px;
padding-right: 2px;
padding-top: 2px;
top: 0px;
width: 100%;
height: 44px;
position: fixed;
z-index: 9999;
box-shadow:0px 1px 2px;
}
#dropfish_menu {
width: 90%;
height: 44px;
margin: 0 auto;
}
#dropfish_menu ul {
width: 90%;
height: 44px;
}
#dropfish_menu ul li {
float: left;
padding: 14px 0px;
margin-top: -1px;
}
#dropfish_menu a {
color: #ffffff;
text-shadow:0 -1px 0 #000000;
padding: 14px 16px;
font-size: 14px;
}
#dropfish_menu a:hover {
margin-top: 0px;
padding: 14px 16px;
/* background-color:#cdcdcd; */
background-repeat: repeat;
background-color: #313131;
background-image: url("images/top-bar-bg.png");
background-position: 50% 75%;
cursor: pointer;
}
.active {
background-color: #313131;
background-image: url("images/top-bar-bg.png");
background-position: 50% 75%;
}
html bit for the menu
<div id="dropfish">
<div id="dropfish_menu">
<ul>
<div style="float:left;margin-left:-128px;">
<li><img src="http://opcdn.otaku-plus.com/themes/plus/images/logo.png" height="34px" style="margin-top: -8px;margin-right: 8px; cursor: pointer;" id="phx_return_logo"/></li>
<li>Web</li>
<li>Anime</li>
<li>Manga</li>
<li>News</li>
<li>Events</li>
<li>More</li>
</div>
<div style="float:right;margin-right:-128px;">
<li>Register</li><li>Sign in</li><li>Preferences</li>
</div>
</ul>
</div>
</div>
can some one tell me what is wrong with my CSS? or HTML
I made a possible solution to your problem. See this
#mainNav is floating left and #login is floating right.
I adjusted your mark up.