本帖最后由 天婷a 于 2009-11-20 13:01 编辑
熬夜转风格,不小心看见用测试版时的风格,就把这个幻灯片给折了下来,现在我也用到我八卦频道去了,呵呵,帖出来,有喜欢的就拿去用,这是官方默认代码,我只是修改了大小。
小建议:你可以设置调用指定的图片,比如精华I 。然后,把你想要在这个幻灯片显示出图片的资讯设置精华I,同时制作合适的图片,并在发布资讯时,将要显示在这个幻灯片里的图片作为第一张上传,
- 模板中写入
- <div class="col410">
- <div id="supehot">
- <!--{block name="spacenews" parameter="haveattach/2/order/i.dateline DESC/limit/0,4/cachetime/83400/subjectlen/40/subjectdot/1/cachename/hotnewspic"}-->
- <div class="box_l" id="index_focus_turn">
- <!--{if !empty($_SBLOCK['hotnewspic'])}-->
- <div id="index_focus_turn_pic">
- <div id="index_focus_turn_picList" style="left:0; top:0;">
- <ul>
- <!--{loop $_SBLOCK['hotnewspic'] $pkey $pvalue}-->
- <li><a href="$pvalue[url]"><img src="$pvalue['a_filepath']" alt="" /></a></li>
- <!--{/loop}-->
- </ul>
- </div>
- <div id="index_focus_turn_opvdiv"></div>
- <div id="index_focus_turn_tx">
- <ul>
- <!--{eval $i = 0}-->
- <!--{loop $_SBLOCK['hotnewspic'] $key $value}-->
- <!--{eval $current = ($i == 0 ? 'current' : 'normal');}-->
- <li class="$current">$value[subject]</li>
- <!--{eval $i++}-->
- <!--{/loop}-->
- </ul>
- </div>
- </div>
- <div id="index_focus_turn_btn">
- <ul>
- <!--{eval $i = 0}-->
- <!--{loop $_SBLOCK['hotnewspic'] $bkey $bvalue}-->
- <!--{eval $current = ($i == 0 ? 'current' : 'normal');}-->
- <li class="$current"><img src="$bvalue[a_thumbpath]" alt="" /></li>
- <!--{eval $i++}-->
- <!--{/loop}-->
- </ul>
- </div>
- <!--{/if}-->
- </div>
- </div>
- </div><!--col410-->
复制代码 以下CSS属性代码,复制到CSS文件的最底部,注意,是最底部,防止CSS属性冲突。
- CSS样式:
- #index_focus_turn { border:1px solid #DEDEDE; background:#F8F8F8; }
- #index_focus_turn_pic { display:inline; position:relative; float:left; width:470px; height:225px; overflow:hidden; margin:10px 0 0 10px; }
- #index_focus_turn_picList { position:absolute; }
- #index_focus_turn_picList li { width:470px; height:225px; overflow:hidden; }
- #index_focus_turn_picList img { width: expression(470 / this.width * this.height > 225 ? 470 : this.width * 225 / this.height); max-width: 410px; min-width: 410px;}
- #index_focus_turn_btn { display:inline; float:right; width:91px; margin:9px 9px 0 0; }
- #index_focus_turn_btn li { width:91px; height:57px; cursor:pointer; filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; }
- #index_focus_turn_btn img { width:75px; height:45px; margin:7px 0 0 11px; }
- #index_focus_turn_btn .current { background:url(../images/focus_trun_btnbg.gif) no-repeat; filter:alpha(opacity=100); -moz-opacity:1.0; opacity:1.0; }
- #index_focus_turn_opvdiv { position:absolute; left:0; bottom:0; width:470px; height:25px; background:#fff; filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; }
- #index_focus_turn_tx { position:absolute; left:8px; bottom:2px; color:#000; }
- #index_focus_turn_tx span { font-size:12px !important; }
- #index_focus_turn_tx .normal { display:none; }
- .column{ border:0px # solid}
- .col410{ width:583px; overflow:hidden; float:left;}
复制代码 图片不动,是忘了JS了,把JS放进去就可以了- function addLoadEvent(func){
- var oldonload = window.onload;
- if (typeof window.onload != 'function') {
- window.onload = func;
- } else {
- window.onload = function(){
- oldonload();
- func();
- }
- }
- }
- function moveElement(elementID,final_x,final_y,interval) {
- if (!document.getElementById) return false;
- if (!document.getElementById(elementID)) return false;
- var elem = document.getElementById(elementID);
- if (elem.movement) {
- clearTimeout(elem.movement);
- }
- if (!elem.style.left) {
- elem.style.left = "0px";
- }
- if (!elem.style.top) {
- elem.style.top = "0px";
- }
- var xpos = parseInt(elem.style.left);
- var ypos = parseInt(elem.style.top);
- if (xpos == final_x && ypos == final_y) {
- return true;
- }
- if (xpos < final_x) {
- var dist = Math.ceil((final_x - xpos)/2);
- xpos = xpos + dist;
- }
- if (xpos > final_x) {
- var dist = Math.ceil((xpos - final_x)/2);
- xpos = xpos - dist;
- }
- if (ypos < final_y) {
- var dist = Math.ceil((final_y - ypos)/2);
- ypos = ypos + dist;
- }
- if (ypos > final_y) {
- var dist = Math.ceil((ypos - final_y)/2);
- ypos = ypos - dist;
- }
- elem.style.left = xpos + "px";
- elem.style.top = ypos + "px";
- var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
- elem.movement = setTimeout(repeat,interval);
- }
- function classNormal(focus_turn_btn,focus_turn_tx){
- var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
- var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
- for(var i=0; i<focusBtnList.length; i++) {
- focusBtnList[i].className='normal';
- focusTxList[i].className='normal';
- }
- }
- function classCurrent(focus_turn_btn,focus_turn_tx,n){
- var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
- var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
- focusBtnList[n].className='current';
- focusTxList[n].className='current';
- }
- function newsfocusChange() {
- if(!$('news_focus_turn')||!$('news_focus_turn_btn')) return;
- $('news_focus_turn').onmouseover = function(){atuokey = true};
- $('news_focus_turn').onmouseout = function(){atuokey = false};
- var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
- if(!focusBtnList||focusBtnList.length==0) return;
- var listLength = focusBtnList.length;
- focusBtnList[0].onmouseover = function() {
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- if (listLength>=2) {
- focusBtnList[1].onmouseover = function() {
- moveElement('news_focus_turn_picList',-400,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
- }
- }
- if (listLength>=3) {
- focusBtnList[2].onmouseover = function() {
- moveElement('news_focus_turn_picList',-800,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
- }
- }
- if (listLength>=4) {
- focusBtnList[3].onmouseover = function() {
- moveElement('news_focus_turn_picList',-1200,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
- }
- }
- }
- setInterval('newsautoFocusChange()', 5000);
- var atuokey = false;
- function newsautoFocusChange() {
- if(!$('news_focus_turn_btn')) return;
- if(atuokey) return;
- var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
- var listLength = focusBtnList.length;
- for(var i=0; i<focusBtnList.length; i++) {
- if (focusBtnList[i].className == 'current') var currentNum = i;
- }
- if (currentNum==0&&listLength!=1 ){
- moveElement('news_focus_turn_picList',-400,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
- }
- if (currentNum==1&&listLength!=2 ){
- moveElement('news_focus_turn_picList',-800,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
- }
- if (currentNum==2&&listLength!=3 ){
- moveElement('news_focus_turn_picList',-1200,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
- }
- if (currentNum==3){
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- if (currentNum==1&&listLength==2 ){
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- if (currentNum==2&&listLength==3 ){
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- }
- function indexfocusChange() {
- if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
- $('index_focus_turn').onmouseover = function(){atuokey = true};
- $('index_focus_turn').onmouseout = function(){atuokey = false};
- var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
- if(!focusBtnList||focusBtnList.length==0) return;
- var listLength = focusBtnList.length;
- focusBtnList[0].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- if (listLength>=2) {
- focusBtnList[1].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,-225,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
- }
- }
- if (listLength>=3) {
- focusBtnList[2].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,-450,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
- }
- }
- if (listLength>=4) {
- focusBtnList[3].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,-675,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
- }
- }
- }
- setInterval('indexautoFocusChange()',5000);
- var atuokey = false;
- function indexautoFocusChange() {
- if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
- if(atuokey) return;
- var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
- var listLength = focusBtnList.length;
- for(var i=0; i<listLength; i++) {
- if (focusBtnList[i].className == 'current') var currentNum = i;
- }
- if (currentNum==0&&listLength!=1 ){
- moveElement('index_focus_turn_picList',0,-225,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
- }
- if (currentNum==1&&listLength!=2 ){
- moveElement('index_focus_turn_picList',0,-450,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
- }
- if (currentNum==2&&listLength!=3 ){
- moveElement('index_focus_turn_picList',0,-675,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
- }
- if (currentNum==3 ){
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- if (currentNum==1&&listLength==2 ){
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- if (currentNum==2&&listLength==3 ){
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- }
- addLoadEvent(newsfocusChange);
- addLoadEvent(indexfocusChange);
复制代码 |