用js實現的DIV+CSS編輯器代碼_經驗交流

來源:互聯網
上載者:User
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DIV+CSS編輯器</title> <META http-equiv=Content-Type content="text/html; charset=gb2312"> <meta content="all" name="robots" /> <meta name="description" content="DIV+CSS編輯器是一個線上編輯DIV+CSS的線上編輯工具" /> <meta content="DIV+CSS編輯器,線上編輯,DIV+CSS,DIV+CSS工具,線上工具" name="keywords" /> <style type="text/css" media="screen"> <!-- html,body{height:100%;}*{font-size:12px;}.vcsseffect{background-color:#fff;background-image:url(grid.gif);}.hiddenObj{display:none;}.normal_input{border:1px solid #84a1bd;background-color:#fff;height:18px;}.hover_input {border:1px solid #9ecc00;background-color:#fff;height:18px;}.vcssDetail{padding: 15px;padding-top:0px;}.MainDialogCSS{ width:550px; margin-right: auto; margin-left: auto; }.DetailCSSboxModel{ height:100%; margin-right: auto; margin-left: auto; }.MainBody{ height:400px; width: 760px; margin-left: auto; margin-right: auto; } --> </style> </head><OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></oBJECT> <body> <p align="center"> 線上DIV+CSS編輯器 </p> <p> 類/標籤/ID:<input name="vcssIdentName" id="vcssIdentName" value=".style1" class="normal_input" onmouseover="select();" onMouseOut="event.cancelBubble=true;this.className='normal_input';" /> 所有數值都不用輸入單位; 寬:<input name="vcssWidth" type="text" class="normal_input" id="vcssWidth" value="" size="8" /> 高:<input name="vcssHeight" type="text" class="normal_input" id="vcssHeight" value="" size="8" /> 背景色:<input name="vcssBackgroundColor" type="text" class="normal_input" id="vcssBackgroundColor" onMouseOut="event.cancelBubble=true;this.className='normal_input';" value="" size="8" onClick="callColorDlg(this)" /> 前景色彩:<input name="vcssColor" type="text" class="normal_input" id="vcssColor" value="" size="8" onMouseOut="event.cancelBubble=true;this.className='normal_input';" onClick="callColorDlg(this)" /> 邊框:<input name="vcssBorderWidth" onclick="value=1;vcssBorderdStyle.value='solid';" type="text" class="normal_input" id="vcssBorderWidth" value="" size="8" /> 顏色:<input name="vcssBorderColor" type="text" class="normal_input" id="vcssBorderColor" value="" size="8" onClick="callColorDlg(this)" onMouseOut="event.cancelBubble=true;this.className='normal_input';" /> <select name="vcssBorderdStyle" id="vcssBorderdStyle" onclick="if(value=='')value='solid';"> <option selected>選擇<option value="solid">solid<option value="dotted">dotted<option value="none">none<option value="hidden">hidden<option value="dashed">dashed<option value="double">double<option value="groove">groove<option value="ridge">ridge<option value="inset">inset<option value="outset">outset</select> 外間距 Margin :<input name="vcssMargin" type="text" onKeyDown="if(event.keyCode==32)this.value+='px';" class="normal_input" id="vcssMargin" value="" size="20" /> 如:10px 2px 內間距 Padding:<input name="vcssPadding" type="text" onKeyDown="if(event.keyCode==32)this.value+='px';" onBlur="if(this.value!='' && !isNaN(this.value.substring(this.value.length-1)))this.value+='px';" class="normal_input" id="vcssPadding" value="" size="20" /> 如:10px 2px 浮動: 左<input type="radio" name="vcssFloat" onClick="if(this.checked)vcssFloatResult.value=this.value" value="left"> 右<input name="vcssFloat" type="radio" onClick="if(this.checked)vcssFloatResult.value=this.value" value="right"><input name="vcssFloat" type="radio" class="hiddenObj" id="unsetFloat" onClick="if(this.checked)vcssFloatResult.value='';" /> × <input name="vcssFloatResult" type="hidden" /> 顯示:<select name="vcssDisplay" id="vcssDisplay"> <option selected>選擇 <option value="block">block <option value="inline">inline <option value="none">none </select> 可見:<input type="radio" name="vcssVisibility" value="visible" onClick="if(this.checked)vcssVisibilityResult.value=this.value">可見 <input type="radio" name="vcssVisibility" value="hidden" onClick="if(this.checked)vcssVisibilityResult.value=this.value">隱藏 <input type="radio" name="vcssVisibility" class="hiddenObj" id="unsetVisibility" onClick="if(this.checked)vcssVisibilityResult.value='';" />× <input name="vcssVisibilityResult" type="hidden" /> 文本對齊:<select name="vcssTextAlign" id="vcssTextAlign" onclick="if(value=='')value='center';"> <option selected>選擇</option> <option value="left">left</option> <option value="center">center</option> <option value="right">right</option> </select> 行高:<input name="vcssLineHeight" type="text" class="normal_input" id="vcssLineHeight" onMouseOut="event.cancelBubble=true;this.className='normal_input';" value="" size="8" /> <select name="vcssLineUnit" id="select5"> <option value="%">%</option> <option selected>無</option> <option value="px">px</option> </select> 文字縮排:<input name="vcssTextIndent" type="text" class="normal_input" id="vcssLineHeight4" value="" size="8" /> 文本:<input name="vcssFontSize" type="text" class="normal_input" id="vcssFontSize" value="12px" size="5" /> 字型: <select name="vcssFontFamily" id="vcssFontFamily" onclick="if(value=='')value='Arial';"><option selected>選擇</option><option value="宋體">宋體<option value="黑體">黑體<option value="Arial">Arial<option value="微軟雅黑">雅黑</select> 粗細:<input name="vcssFontWeight" type="text" class="normal_input" id="vcssLineHeight3" value="" size="8" onMouseOut="event.cancelBubble=true;this.className='normal_input';" /> 效果:<input type="radio" name="vcssTextDecoration" value="underline" onClick="if(this.checked)vcssDecorationResult.value=this.value">底線 <input type="radio" name="vcssTextDecoration" value="none" onClick="if(this.checked)vcssDecorationResult.value=this.value">無 <input type="radio" name="vcssVisibility" class="hiddenObj" id="unsetDecoration" onClick="if(this.checked)vcssDecorationResult.value='';" />× <input name="vcssDecorationResult" type="hidden" /> 背景圖片:<input name="vcssBackgroundImage" type="file" class="normal_input" id="vcssBackgroundImage"> 重複:<select name="vcssBackgroundRepeat" id="vcssBackgroundRepeat" onclick="if(value=='')value='no-repeat';"><option selected>選擇<option value="repeat-x">橫向重複<option value="repeat-y">縱向重複<option value="no-repeat">不重複</select> 水平位置:<input name="vcssBackgroundPositionX" type="text" class="normal_input" id="vcssBackgroundPositionX" value="" size="5" /> 垂直位置:<input name="vcssBackgroundPositionY" type="text" class="normal_input" id="vcssBackgroundPositionY" value="" size="5" /> 附件:<select name="vcssBackgroundAttachment" id="vcssBackgroundAttachment" onclick="if(value=='')value='fixed';"><option selected>選擇<option value="fixed">固定<option value="scroll">滾動</select> 垂直對齊:<select name="vcssVerticalAlign" id="vcssVerticalAlign" onclick="if(value=='')value='middle';"> <option selected>選擇</option> <option value="middle">middle</option> <option value="bottom">bottom</option> <option value="auto">top</option> <option value="auto">auto</option> <option value="baseline">baseline</option> </select> 清除:<select name="vcssClear" id="vcssClear" onclick="if(value=='')value='both';"> <option selected>選擇</option> <option value="left">left</option> <option value="right">right</option> <option value="both">both</option> </select> Overflow:<select name="vcssOverflow" id="vcssOverflow" onclick="if(value=='')value='hidden';"> <option selected>選擇</option> <option value="scroll">scroll</option> <option value="auto">auto</option> <option value="hidden">hidden</option> </select> 定位:<select name="vcssPosition" id="vcssPosition"> <option selected>選擇</option> <option value="absolute">絕對</option> <option value="relative">相對</option> </select> Z座標:<input name="vcssZIndex" id="vcssZIndex" class="normal_input" size="5" value="" onMouseOut="event.cancelBubble=true;this.className='normal_input';" /> left:<input name="vcssLeft" id="vcssLeft" class="normal_input" size="4" value="" /> top:<input name="vcssTop" id="vcssTop" class="normal_input" size="4" /> right:<input name="vcssRight" id="vcssRight" class="normal_input" size="4" /> bottom:<input name="vcssBottom" id="vcssBottom" class="normal_input" size="4" /> UL列表:類型<select name="vcssListStyleType" id="vcssListStyleType" onclick="if(value=='')value='none';"> <option selected>選擇</option> <option value="none">none</option> <option value="disc">disc</option> <option value="circle">circle</option> <option value="square">square</option> <option value="decimal">decimal</option> </select> 映像:<input name="vcssListStyleImageBtn" type="button" id="vcssListStyleImageBtn" onclick="vcssListStyleImage.click();" value="..."> <input name="vcssListStyleImage" id="vcssListStyleImage" type="file" value="" style="display:none;" /> 位置:<input type="radio" name="vcssListStylePosition" value="inside" onClick="if(this.checked)vcssPositionResult.value=this.value">內 <input type="radio" name="vcssListStylePosition" value="outside" onClick="if(this.checked)vcssPositionResult.value=this.value">外 <input type="radio" name="vcssVisibility" class="hiddenObj" id="unsetPosition" onClick="if(this.checked)vcssPositionResult.value='';" />× <input name="vcssPositionResult" type="hidden" /> 游標: <select name="vcssCursor" id="vcssCursor" onclick="if(value=='')value='pointer';"> <option selected>選擇</option> <option value="default">預設</option> <option value="pointer">手</option> <option value="text">文本</option> <option value="move">移動</option> <option value="crosshair">crosshair</option> <option value="default">default</option> <option value="pointer">pointer</option> <option value="hand">hand</option> <option value="move">move</option> <option value="help">help</option> <option value="wait">wait</option> <option value="text">text</option> <option value="w-resize">w-resize</option> <option value="s-resize">s-resize</option> <option value="n-resize">n-resize</option> <option value="e-resize">e-resize</option> </select> <input name="vcssOk" type="button" id="vcssOk" onClick="setSelectionWithCss(1);" value="確定"> <input name="vcssCancel" type="button" id="vcssCancel" value="取消"> <input name="vcssView" type="button" id="vcssView" onClick="setSelectionWithCss(2);" value="應用"> <input name="vcssImport" type="button" id="vcssImport" value="@import.."> <input name="vcssSave" type="button" id="vcssSave" value="儲存.."> <input name="vcssLoad" type="button" id="vcssLoad" value="載入.."> <fieldset style="padding:10px; "><legend>實際應用效果如下</legend> Effect of This Rule Shows You at here! 工具啦 (www.tool.la) 給你最全、最好的工具! </fieldset></p> <hr /> <textarea name="cssTextValue" cols="100" rows="5" id="cssTextValue"></textarea> <input name="vcssView" type="button" id="vcssView" onclick="window.clipboardData.setData('text',document.all.cssTextValue.value);alert('CSS已儲存到剪貼簿');" value="複製到剪下板"> <textarea name="cssTextValueCompare" cols="100" rows="5" id="cssTextValueCompare"></textarea> <input name="vcssView2" type="button" id="vcssView" onclick="window.clipboardData.setData('text',document.all.cssTextValueCompare.value);alert('CSS已儲存到剪貼簿');" value="複製到剪下板"> <hr /> 這是一個使用了複雜的樣式的DIV,你可以使用擷取CSS來擷取這個CSS <input type="button" id="vcssView" onclick="getSelectionWithCss();setSelectionWithCss()" value="擷取左側DIV樣式"> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.