开发者

Why can't change color of string resulting from script?

开发者 https://www.devze.com 2023-02-01 09:19 出处:网络
I don\'t konw how to change the color of this string to white. I barely handle PHP and HTML so the Script is beyond me. I\'m not quite sure how you format the text resulting from it. I just want it to

I don't konw how to change the color of this string to white. I barely handle PHP and HTML so the Script is beyond me. I'm not quite sure how you format the text resulting from it. I just want it to be white.

This is the code:

<div style="font-size: large; float:right; color: white; display:inline; padding: 14px;">
<script language="javascript">
document.write('<a href="?s=' + geoip_city() + '">¿Estás en ' + geoip_city() +'?</a>');
</script>
</div>

Also just in case you want to check it out this is where i'm 开发者_运维技巧testing it, it's at the far right of the menu.

http://chusmix.com/

Anyway, It maybe a really stupid question with an obvious answer (I hope so). Thanks


It doesn't work because you probably have other CSS rules that set the links' colors.
It works with normal text: http://jsbin.com/equxa4

Consider a CSS solution:

HTML:

<div class="City">...</div>

CSS:

.City {font-size: large; float:right; color: white; display:inline; padding: 14px;}
.City a {color:white;}

You may have to set the different states of the link, depending on your CSS:

.City a:link, .City a:visited, .City a:active, .City a:hover {color:white;}


Looking at FireBug, it looks like _yellow.css and style.css are both overriding the style that would be inherited by the parent div's inline style. You could add a class for this link:

.white-link {
    color:white;
}

and then update your script:

<script language="javascript">
document.write('<a class="white-link" href="?s=' + geoip_city() + '">¿Estás en ' + geoip_city() +'?</a>');
</script>

OR define the style inline, as you've done with the div:

<script language="javascript">
document.write('<a style="color:white" href="?s=' + geoip_city() + '">¿Estás en ' + geoip_city() +'?</a>');
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号