"/>
首页 \ 问答 \ 如何在CSS中进行自定义文本编辑并在学校项目中获取错误(How to do custom text editing in CSS and getting a error in a school project)

如何在CSS中进行自定义文本编辑并在学校项目中获取错误(How to do custom text editing in CSS and getting a error in a school project)

这是该页面的代码

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Ian Kenji Part 2 Web Development</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="Description" lang="en" content="Ian Kenji Part 2 Web Development">
    <meta name="author" content="Ian Kenji">
    <meta name="robots" content="index, follow">
    <script>
      function startTime() {
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        m = checkTime(m);
        s = checkTime(s);
        document.getElementById('txt').innerHTML =
        h + ":" + m +  " o'clock";
        var t = setTimeout(startTime, 500);
      }
      function checkTime(i) {
        if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
        return i;
      }
    </script>

    <script>
      function greetings(){
        var now = new Date();
        if (now.getHours() < 5) {
          document.getElementById('greeting').innerHTML =
          "What are you doing up so late?";
        }
        else if (now.getHours() < 9) {
          document.getElementById('greeting').innerHTML =
          "Good Morning!";
        }
        else if (now.getHours() < 17) {
          document.getElementById('greeting').innerHTML =
          "No surfing during working hours!";
        }
        else {
          document.getElementById('greeting').innerHTML =
          "Good Evening!";
        }
      }
    </script>

    <!-- icons -->
    <link rel="apple-touch-icon" href="assets/img/apple-touch-icon.png">
    <link rel="shortcut icon" href="favicon.ico">

    <!-- Override CSS file - add your own CSS rules -->
    <link rel="stylesheet" href="assets/css/styles.css">
  </head>
  <body>
    <div class="container">
      <div class="header">
        <h1 class="header-heading">James Bond Spectre</h1>
      </div>
      <div class="nav-bar">
      <ul class="nav">
        <li><a href="homepage.html">Home</a></li>
        <li><a href="images.html">Images</a></li>
        <li><a href="video.html">Video</a></li>
        <li><a href="audio.html">Audio</a></li>
        <li><a href="text.html">Text</a></li>
        <li><a href="documentation.html">Documentation</a></li>
        <li><a href="validation.html">Validation</a></li>
        <li><a><p><br></p><body onload="greetings(); startTime()"><div id="txt"></div><div id="greeting"></div></a></li>
      </ul>
    </div>
    <div class="content">
      <div class="main">

        <h1>Images</h1>
        <hr>
        <hr>
        <h4>Bond, James Bond</h4>
        <center><img src="assets/img/Spectre1.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic5.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic2.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic3.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic4.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>

        <!-- <iframe width="560" height="315" src="https://www.youtube.com/embed/7GqClqvlObY" frameborder="0" allowfullscreen></iframe> -->

        </div>
      </div>
      <div class="footer">
        &copy; Copyright 2015 Ian Kenji
      </div>
    </div>
  </body>
</html>

我知道它真的很草率,但我对此有点新意。 这是我的问题,当通过验证器运行时,我收到此错误

开始标记主体,但相同类型的元素已经打开。 来自第72行,第28栏; 到第72行,第67栏

<li><a><p><br></p><body onload="greetings(); startTime()"><div id="txt"></div><div id="greeting"></div></a></li>

另外我被告知,使用<center>来中心图片已经过时了,我应该使用CSS。 但是,我有一个问题,因为我需要一些图片为中心,其中一些不是。 我怎样才能做到有些是,有些不是?

我能做些什么来解决这个错误?


This is the code for the page

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Ian Kenji Part 2 Web Development</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="Description" lang="en" content="Ian Kenji Part 2 Web Development">
    <meta name="author" content="Ian Kenji">
    <meta name="robots" content="index, follow">
    <script>
      function startTime() {
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        m = checkTime(m);
        s = checkTime(s);
        document.getElementById('txt').innerHTML =
        h + ":" + m +  " o'clock";
        var t = setTimeout(startTime, 500);
      }
      function checkTime(i) {
        if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
        return i;
      }
    </script>

    <script>
      function greetings(){
        var now = new Date();
        if (now.getHours() < 5) {
          document.getElementById('greeting').innerHTML =
          "What are you doing up so late?";
        }
        else if (now.getHours() < 9) {
          document.getElementById('greeting').innerHTML =
          "Good Morning!";
        }
        else if (now.getHours() < 17) {
          document.getElementById('greeting').innerHTML =
          "No surfing during working hours!";
        }
        else {
          document.getElementById('greeting').innerHTML =
          "Good Evening!";
        }
      }
    </script>

    <!-- icons -->
    <link rel="apple-touch-icon" href="assets/img/apple-touch-icon.png">
    <link rel="shortcut icon" href="favicon.ico">

    <!-- Override CSS file - add your own CSS rules -->
    <link rel="stylesheet" href="assets/css/styles.css">
  </head>
  <body>
    <div class="container">
      <div class="header">
        <h1 class="header-heading">James Bond Spectre</h1>
      </div>
      <div class="nav-bar">
      <ul class="nav">
        <li><a href="homepage.html">Home</a></li>
        <li><a href="images.html">Images</a></li>
        <li><a href="video.html">Video</a></li>
        <li><a href="audio.html">Audio</a></li>
        <li><a href="text.html">Text</a></li>
        <li><a href="documentation.html">Documentation</a></li>
        <li><a href="validation.html">Validation</a></li>
        <li><a><p><br></p><body onload="greetings(); startTime()"><div id="txt"></div><div id="greeting"></div></a></li>
      </ul>
    </div>
    <div class="content">
      <div class="main">

        <h1>Images</h1>
        <hr>
        <hr>
        <h4>Bond, James Bond</h4>
        <center><img src="assets/img/Spectre1.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic5.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic2.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic3.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>
        <center><img src="assets/img/pic4.jpg" alt="Spectre" style="width:100%;height:100%;"></center>
        <p><br><p>

        <!-- <iframe width="560" height="315" src="https://www.youtube.com/embed/7GqClqvlObY" frameborder="0" allowfullscreen></iframe> -->

        </div>
      </div>
      <div class="footer">
        &copy; Copyright 2015 Ian Kenji
      </div>
    </div>
  </body>
</html>

It is really sloppy I know but I am a little new to this. This is my question, when running it through a validator I get this error

start tag body seen but an element of the same type was already open. From line 72, column 28; to line 72, column 67

<li><a><p><br></p><body onload="greetings(); startTime()"><div id="txt"></div><div id="greeting"></div></a></li>

In addition I am told that the use of <center> to center the pictures is obsolete and that I should use the CSS. However, I have a problem with that as I need some of the pictures to be centered, and some of them not to be. How can I make it so that some are, and some aren't?

And what can I do to fix that error?


原文:https://stackoverflow.com/questions/34215093
更新时间:2020-10-25 22:10

最满意答案

你有2个身体标签。 将第一个替换为第二个并删除第二个。

添加类center到你的CSS是这样的

img.center {
    display: block;
    margin-left: auto;
    margin-right: auto
}

并将该类放在要居中的图像标记上,然后删除中心标记。

<img src="assets/img/Spectre1.jpg" class="center" />

阅读更多关于CSS的信息: http//www.w3.org/Style/Examples/007/center.en.html


You have 2 body tags. Replace the 1st with the 2nd and remove the 2nd.

Add class center to your css something like this

img.center {
    display: block;
    margin-left: auto;
    margin-right: auto
}

and put that class on image tag that you want to center then remove the center tag.

<img src="assets/img/Spectre1.jpg" class="center" />

Read more about css here: http://www.w3.org/Style/Examples/007/center.en.html

2015-12-11

相关问答

更多

在rails上使用自定义CSS(Windows)(Using custom css on rails (Windows))

他们解决的方法是将所有我的定制文件(css,js等)添加到文件初始化程序/ assets.rb。 自那以后我没有任何其他问题。 但是,这样做是对的吗? 按照我的方式编辑这个文件。我问这是因为我正在跟着一个Lynda教程,那里的文件没有改变,只有清单。 好吗? They way that I solved it was adding all my custom files (css, js, etc) to the file initializers/assets.rb. I didnt have ...

HTML和CSS学校项目(HTML and CSS school project)

height和width必须有一个单位,如px,dpi等。 #wrapper { width: 1024px; height: 768px; background-color: #E1E0E0; } #banner { width: 1024px; height: 220px; background-color: #6E6A6A; } #menuTop { wi ...

我无法在bootstrap项目中编辑我的custom.css(I can't edit my custom.css in a bootstrap project)

你使用错误的行注释, 改变这个: <!--TEXTOS--> h1{ font-size:40px; color:#FFF; background-color: forestgreen; } <!--Carousel--> .carousel-inner { position: relative; overflow: hidden; width: 100%; margin-top: -20px; } 对此: /*TEXTOS*/ h ...

JTextFields和我的学校项目(JTextFields and with my school project)

问题是你将侦听器设置为JPanel ,如果你将它设置为它工作的JTextField 。 我附上下面的代码,但是,JLabel可能会有所帮助。 我的意思是,它更容易,更有条理等等。但您必须了解布局的工作原理。 不管怎样,这就是我的看法: ElementRunner.java (大写元素)。 public class ElementRunner { public static void main(String[] args) { MyWindow panel = new My ...

学校项目的文本对齐(Text alignment on school project)

你必须像这样改变你的HTML代码结构.... body > h1 body > section.a > h2 > ol body > section.b > h2 > ol 现在在CSS中你必须做一些改变,比如... section.a, section.b { width:49%; } section.a{ float:left; } section.b{ float:right; } body { /*background: url("DC.jpg") no-re ...

如何创建自定义文本编辑控件?(How to create a custom text editing control?)

#develop的开发人员在他们的书“解析C#应用程序”中讨论了创建功能丰富的版本控件的主题,包括语法高亮,代码完成等。 http://www.icsharpcode.net/OpenSource/SD/InsideSharpDevelop.aspx (我想你不能再买它了,链接说可以免费下载,但链接好像坏了) 这本书基本上解释了#develop(pre V1,因此它有点过时)的核心功能,包括代码编辑器和(在这个过程中发生的错误)。 The topic of creating a feature r ...

我在使用tkinter的python中有错误,需要帮助(学校项目)(I have an error in python with tkinter and need help(school project))

好的,所以我发现了一些错误。 第一个是您在函数内部引用全局变量 (索引)。 要做到这一点,你需要告诉python你正在使用全局变量。 def menueauswahl(taste): global index print(taste) 此外,您还需要将第61行中的函数名称更改为menuaufbau en ()。 Okay so I caught a couple of errors. The first is that you are referencing a global v ...

如何在CSS中进行自定义文本编辑并在学校项目中获取错误(How to do custom text editing in CSS and getting a error in a school project)

你有2个身体标签。 将第一个替换为第二个并删除第二个。 添加类center到你的CSS是这样的 img.center { display: block; margin-left: auto; margin-right: auto } 并将该类放在要居中的图像标记上,然后删除中心标记。 <img src="assets/img/Spectre1.jpg" class="center" /> 阅读更多关于CSS的信息: http : //www.w3.org/Style/E ...

相关文章

更多

最新问答

更多
  • 如何保护Solr只允许SELECT请求给用户并禁止其他任何东西?(How to secure Solr to allow SELECT request to only users and disallow anything else?)
  • XPath表达式无效/错误TFHpple SWIFT 1.2(XPath Expression not working/incorrect TFHpple SWIFT 1.2)
  • css3 3D变换不能平滑地制作动画(css3 3D transform doesn't animate smoothly)
  • 运行时错误'91'和Outlook.Application = <对象变量或没有设置块变量>?(Run-time error '91' & Outlook.Application = Object variable or With block variable not set?)
  • 慢的webservice问题(Slow webservice problem)
  • textview的不正确对齐方式(Improper alignment of a textview)
  • 在第一步“Hello World”中出现Java错误(Cannot run “Hello World” program in Eclipse)
  • 为什么十六进制地址是14个字符?(why the hex address is 14 character?)
  • 如何在Python中的不同类中使用变量?(How to use variable in different classes in Python?)
  • asp:GridView HYPERLINKFIELD - datanavigateurlformatstring中的asp代码(asp:GridView HYPERLINKFIELD - asp code inside datanavigateurlformatstring)
  • 关于adaboost算法(About adaboost algorithm)
  • 在Matlab上内置图像(Built in Images on Matlab)
  • java swing:输入键事件时焦点丢失(java swing: Focus lost on enter key event)
  • C#中的通用约束,T是相同的TSomethingElse,对吧?(Generic constraints in C#, T is the same TSomethingElse, right?)
  • 从mybatis中的光标获取数据(Fetching data from cursor in mybatis)
  • 在运行时从XML构建对象的最佳方法(Best way for building objects out of XMLs at runtime)
  • 在整个窗口中拉伸sf :: Sprite(Stretch sf::Sprite across entire window)
  • Selenium Node API Web驱动程序等待超时处理程序(Selenium Node API web driver wait timeout handler)
  • 函数使用并且是map的一部分(循环依赖?)(Function uses and is part of map (circular dependency?))
  • 是否可以在C ++ 14中使用可选模板参数创建类型元组?(Is possible to make a tuple of types with optional template parameters in C++14?)
  • PHP从窗帘后面打印/ f(PHP prints /f from behind the curtains)
  • JFrame的contentPane的LayoutManager(LayoutManager of JFrame's contentPane)
  • 用于Instagram Feed的图像滚动(Image Roll Overs for Instagram Feed)
  • 如何显示拉伸字体(双倍宽度/高度)?(How to display stretched font (double width/height)?)
  • 文件操作API在fileapi.h和stdio.h中的WP8差异?(WP8 differences between file manipulation APIs in fileapi.h and stdio.h?)
  • 保存失败后Rails没有回滚事务()(Rails not rolling back transaction after failed save())
  • jqgrid中的分页问题与数组数据(Pagination problem in jqgrid with array data)
  • 重定向时,通过其他页面上的URL调用javascript函数(Call javascript function through url on otherpage while Redirecting)
  • 如何使用InvokeCommandAction调用我的方法并传入参数?(How do I go about using InvokeCommandAction to call a method of mine and pass in parameters?)
  • Jquerymobile按钮仅显示页面的第一个外观(Jquerymobile buttons are shown only first apperance of the page)