dsqa6272 2012-03-03 01:42 采纳率: 0%
浏览 47
已采纳

使用表单编辑CSS和HTML

I want create a form to edit the style and html content of a template web page.

Form Page has:

  • An input to enter a h1 heading for the page
  • A dropdown box to choose a font for the h1
  • A dropdown box to select text size
  • An input to enter a subtitle
  • Controls to change formatting
  • etc

This generates Page B, which is mostly formatted already with css, but uses the inputs from the form to edit some styles, like fonts and colours.

I could do this easily if I just posted the the form to Page B, and inlined the css with something like this:

<h1 style="font-size: <?php echo $_POST['h1-font-size'] ?>pt">
    <?php echo $_POST['h1-title']?>
</h1>

But I would prefer to keep the formatting separate from the HTML as these pages may need to be edited by hand in the future. I also want to save the resultant html page and css file for future use.

What is the best and easiest way to do this? I could paste the whole css file into PageB and make page B write it to the server with the specified changes, but this doesn't seem like a very elegant way of doing things.

Background: comp-sci degree, not much web experience.

  • 写回答

2条回答 默认 最新

  • dpxf81245 2012-03-03 01:49
    关注

    I'd suggest set up a stylesheet with all the properties you want to be able to have edited.

    Create a 'field' in a database (or flat file) for each field you want to be editable from the front-end.

    Then make your interface for inputs match these fields.

    Save your inputs back into the database.

    Write an output function to write your css files from the database if you want to save them down again.

    This depends on the scale of the task as to which way will save you the most time now and in the future.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题