动态页面控制页面样式

当前位置: >
> 怎么从一个页面控制另一个页面的样式
怎么从一个页面控制另一个页面的样式
ryueifu & at
如何从一个页面控制另一个页面的样式
如图,这是通过页面框架凑在一起的页面,左右是两个不同的页面,左右分别暂命名为A、B,如何通过点击B中的某个复选框,让A中的菜单某个项高亮一下,因为不在同一个页面,所以感觉不简单的样子。
引用:  Quote: 引用:  iframe页面与父页面有引用关系,主页面通过&iframe对象.contentWindow访问iframe页面window对象,iframe页面通过window.parent访问父页面window对象;非跨域情况下可以互相操作
不是很懂,可以举个例子来说明一下吗
var&frmwnd&=&document.getElementById('iframeID').contentW
frmwnd.document.getElementById('divid').style.backgroundColor="Red";ryy_2006 & &
& & (0)(0)不好意思,这方面我不懂ryy_2006 & &
& & (0)(0)
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
忽然没有了方向感
LOFTER精选
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'CSS控制页面的几种样式',
blogAbstract:'CSS控制页面的样式有四种,分别是行内样式,嵌入样式,外部样式,导入样式;\r\n&span style=\"color:\"& 行内样式&/span&\r\n嵌入样式:\r\n&style type=\"text/css\"&\r\n&/style&\r\n外部样式:\r\n&link rel=\"stylesheet\" href=\"css.css\" /&\r\n导入样式:\r\n@import url',
blogTag:'css,div,行内样式,嵌入样式,样式',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:8,
publishTime:8,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'忽然没有了方向感',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}前几天不是有人问如何动态控制网战样式么?
前几天不是有人问如何动态控制网战样式么?
看看这个,不要头晕噢,内容一点都不难
CSS & PHP Author: Scott Leonard Date: 05. February 2004 Rating: 7.67 (3 votes) Nr Reads: 222 Category: Intermediate Type: Tutorial
-------------------------------------------------------------------------------- How to infuse CSS with PHP and a MySQL database.
This tutorial demonstrates the CSS code found in the recently released Gemsites v1.1 (
) and will show you how to get nice CSS built into your PHP code, using a MySQL database.
For any of you with web pages of your own who may wish to learn more about CSS, I've decide to write a small tutorial to help you get started. This tutorial looks at CSS and PHP, so it's for the beginner/intermediate web designer.
I've been working on a bunch of &farkisms& for the Gordie site, and to help illustrate what we're doing here with them, I've decided to show you how the CSS changes with each farkism. A farkism is the little comment that goes with a story, such as Obvious, Asinine, Interesting.
, they have their farkisms designed using photoshop. Because I'm a web designer and I like to drill down to the data, so therefore I had a sidebar with Pete, and we've concocted a way to do what Fark does, but a little differently.
First of all, I have a table of values entered into our data, shown here:
Take a look at the columns: record_id: this is the number associated with the farkism. When you pick it, this number will go into the story id. farkism: this is a lower cased sub-topic bgcol: this is a hex colour code that identifies the colour of the background fgcol: this is a hex colour code that identifies the colour of the font
Setting up the table this way, means we can quickly assign a CSS class to each farkism.
We want our farkisms to appear next to the title of a story that has one associated, but first we have to prepare to add the template.
The following function grabs the details from the database, and outputs a style table that is read by the website.CODE:&?php&?php&function&farkcss(){&$sql&=&'select&record_id,&bgcol,&fgcol&from&gem_ref_farkisms';&$result=&doselect($sql);&if&(mysql_num_rows($result)&&&0)&{&print&'&style&type="text/css"&'.chr(10);&while&(&$fields&=&@mysql_fetch_array($result))&{&print&'.fark'.$fields['record_id'].'{background-color:#'.$fields['bgcol'].';color:#'.$fields['fgcol'].';}'.chr(10);&}&print&'&/style&';&}&}?&The sql statement is passed to a mysql_query function but because I count the number of select statements called, I use a custom function called doselect. That is another tutorial. :-)
If the result of the selection has more results than zero, then w otherwise we just skip it.
We start by printing a style statement, which will have the following output:
&style type=&text/css&&
This opens a CSS style block in the website.
Then for each row of the table, we print: .fark&record_number&{background-color:#&bgcol&;color:#&fgcol&}
The result is a list of CSS:CODE:&style type=&text/css&& .fark1{background-color:#000000;color:#54FF9F;} .fark2{background-color:#000000;color:#FFD700;} .fark3{background-color:#EE6363;color:#000000;} .fark4{background-color:#000000;color:#FFFFFF;} .fark5{background-color:#000000;color:#FFFFFF;} .fark6{background-color:#000000;color:#FFFFFF;} .fark7{background-color:#000000;color:#FFFFFF;} .fark8{background-color:#000000;color:#FFFFFF;} .fark9{background-color:#000000;color:#FFFFFF;} .fark10{background-color:#000000;color:#FFFFFF;} .fark11{background-color:#000000;color:#FFFFFF;} .fark12{background-color:#000000;color:#FFFFFF;} .fark13{background-color:#000000;color:#FFFFFF;} .fark14{background-color:#000000;color:#FFFFFF;} .fark15{background-color:#000000;color:#FFFFFF;} .fark16{background-color:#000000;color:#FFFFFF;} .fark17{background-color:#000000;color:#FFFFFF;} .fark18{background-color:#000000;color:#FFFFFF;} .fark19{background-color:#000000;color:#FFFFFF;} .fark20{background-color:#000000;color:#FFFFFF;} .fark21{background-color:#000000;color:#FFFFFF;} .fark22{background-color:#000000;color:#FFFFFF;} .fark23{background-color:#000000;color:#FFFFFF;} .fark24{background-color:#000000;color:#FFFFFF;} .fark25{background-color:#000000;color:#FFFFFF;} .fark26{background-color:#000000;color:#FFFFFF;} .fark27{background-color:#000000;color:#FFFFFF;} .fark28{background-color:#000000;color:#FFFFFF;} .fark29{background-color:#000000;color:#FFFFFF;} .fark30{background-color:#000000;color:#FFFFFF;} .fark31{background-color:#000000;color:#FFFFFF;} .fark32{background-color:#000000;color:#FFFFFF;} &/style&When we call the farkism, we can change the values in the table, without having to know them in the website.
A good website to find colour reference values is here: [ click ] [
When Gemsites loads a story, we then look at the table of the story to see what farkism it uses.
The following PHP function , draws the farkism next to the title:CODE:&?php&?php&function&printfarkism(&$fid){&if($fid&!=0){&$sql&=&'select&farkism&from&gem_ref_farkisms&where&record_id='.$fid;&$fark_arr&=&array();&$fark_arr&=&mysql_fetch_array(doselect($sql));&$fark_str&=&'';&if($fark_arr)&print&'&&span&class="fark'.$fid.'"&&'.ucwords($fark_arr[0]).'&&/span&&';&}&}?&We take the variable $fid, which is the farkism record_id. We check this number to see if it's not zero, by using the if statement above.
Then we load up the info from the table, but we only need to know the farkism title, because CSS has already been told what to expect, based on each number we send. This is a time saver, and it's speedier than doing all this by hand. Plus if we decide to change colours down the road, it's much easier to change the data, rather than the formatting and code itself. We would only have to quickly change the table in our database, and not any web programming code.
We init an array called $fark_arr, and we stuff it with the result of the doselect request.
Normally we would limit a select like this to only one result by adding &limit 1& to the end of the sql statement, but because the record_id is a primary key, it can only have one result!
If we find the array, we print the result, by printing the following: print '&&span class=&fark'.$fid.'&&&'.ucwords($fark_arr[0]).'&&/span&&';
An & character is just a tag used to represent a hard space character.
XHTML with CSS uses the following convention: &span class=&class&&text&/span&
But because we have a database with lots of different values, we want to assign a different class per value, so we use the above function to filter it through.
This: &span class=&fark'.$fid.'&& Will result in: &span class=&fark1&&
if $fid is equal to 1. It will change the class based on the number sent to the function.
This: &'.ucwords($fark_arr[0]).'& Will print: Review (with a space on either side)
The ucwords function simply capitalizes each word in a sentence. Because it's better for convention, we have stored farkisms in lower case.
So there you go. We have a dynamic system for formatting our farkisms, using CSS and XHTML.
Questions are welcome.
昵称: how172 &时间:
昵称: mgirl &时间:CSS动态控制页面中较长的字符串样式
在前台页面开发的过程中,经常会遇到设置列表里某一列的的长度。如:标题、备注等等
但是某一些又需要根据整个页面的宽度动态的调整他的长度,否则容易出现样式错位,导致阅读困难。
通过CSS的属性来动态控制较长字符串的动态截取,是比较好的解决方式。样式设置如下:
style=&text-overflow: white-space: overflow:&
必须要这三个属性组合使用才能达到效果!
样式设置如下:第一行与第二行的追加了样式的。会根据IE窗口的宽度变化自动设置省略号。
注意:这三个样式必须要都追加才可以。否则无效。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:384043次
积分:4955
积分:4955
排名:第1832名
原创:103篇
转载:169篇
评论:69条
(1)(1)(3)(1)(5)(2)(8)(3)(1)(1)(4)(5)(4)(6)(8)(3)(11)(2)(3)(1)(2)(2)(4)(4)(2)(2)(2)(3)(1)(7)(7)(4)(1)(1)(4)(1)(1)(3)(4)(3)(2)(5)(3)(1)(6)(2)(2)(3)(1)(2)(8)(1)(6)(5)(4)(4)(10)(25)(9)(11)(5)(6)(2)(7)(7)(13)使用CSS控制超链接样式
阅读:936次&&&时间: 17:52:37&&
你对CSS中超链接的概念是否了解,这里和大家分享一下如何用CSS控制超链接样式,超链接通俗地指从一个网页指向一个目标的连接关系。
用CSS控制超链接样式
本文将讲解通过CSS样式或通过CSS来控制超链接样式。这里主要讲文字类型的超链接,超链接的样式包括通过CSS来控制设置超链接有无下划线、超链接文字颜色等样式。
什么是超链接?
超链接通俗地指从一个网页指向一个目标的连接关系,这个目标可以是另一个网页,也可以是相同网页上的不同位置,还可以是一个图片,一个电子邮件地址,一个文件,甚至是一个应用程序。而在一个网页中用来超链接的对象,可以是一段文本或者是一个图片。当浏览者单击已经链接的文字或图片后,链接目标将显示在浏览器上,并且根据目标的类型来打开或运行。
超链接的代码
ahref=&/&target=&_blank& &title=&关于divCSS的网站&DIV+CSS&&
解析如下:
href后跟被链接地址目标网站地址这里是/
_blank--在新窗口中打开链接
_parent--在父窗体中打开链接
_self--在当前窗体打开链接,此为默认值
_top--在当前窗体打开链接,并替换当前的整个窗体(框架页)
◆title后跟链接目标说明,也就是超链接被链接网址情况简要说明,或标题
CSS可控制超链接样式-CSS链接样式如下
a:active是超级链接的初始状态
a:hover是把鼠标放上去时的状况
a:link是鼠标点击时
a:visited是访问过后的情况
超链接样式案例
1、通常对全站超链接样式化方法&
a{color:#333;text-decoration:} &//对全站有链接的文字颜色样式为color:#333; &并立即无下划线text-decoration: &a:hover{color:#CC3300;text-decoration:}//对鼠标放到超链接上文字颜色样式变为 &color:#CC3300; &并文字链接加下划线text-decoration: &&
2、通过链接内设置类控制超链接样式CSS方法
案例超链接代码
ahref=&/&class=&yangshi&&CSS &&
对应CSS代码&
a.yangshi{color:#333;text-decoration:} &a.yangshi:hover{color:#CC3300;text-decoration:} &&
通过这样的设置可以控制链接内的CSS类名为&yangshi&超链接的样式
3、通过对应超链接外的父级的CSS类的CSS样式来控制超链接的样式
案例超链接代码
divclass=&yangshi&&ahref=&/&&CSS&&
对应CSS代码&
.yangshia{color:#333;text-decoration:} &.yangshia:hover{color:#CC3300;text-decoration:} &&
这里值得注意的是a.yangshi与.yangshia的样式CSS代码区别,这里就是常见的通过divCSS来对超链接样式设置案例及分析。
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
[商业源码]&
Copyright &
All Rights Reserved

我要回帖

更多关于 页面样式 的文章

 

随机推荐