如何使我的代码看起来像截图中的样子?

huangapple go评论65阅读模式
英文:

How do I make my code look like the screenshot?

问题

I am stumped. I need help making my code look like the screenshot provided. I am using Microsoft Visual Code.

这是我目前屏幕的样子

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

<!DOCTYPE html>
<html lang="zxx">
<head>
<meta charset="utf-8">
<title>College of Music</title>

<style>
		
	/* Hex Colors: #CDC2B3, #5F3E2F, #C23315, #341C12, #D8B9AB, #862E06, #F0D1C3 */
	
	* {margin: 0; padding: 0}


#wrapper {
	width: 778px;
    margin: auto;
	text-align: left;
}
#header {
	height:320px;
	background: url(images/header.jpg)no-repeat;
		
}
#header div {
	padding: 183px 213px 0px 82px;
}
#header p {
	margin: 0px;
	padding: 0px;
}

#header a {
	color:#FFFFFF;
}
body {
	background: #cdc2b3;
	text-align: center;
	margin: 0px;
	padding: 20px 0px 20px 0px;
	font: 15px "Georgia"; 
	color: #5F3E2F;
}
a {
	color: #5F3E2F;
	font-weight: bold;
	text-decoration: none;
}
a:hover {
	color: #1D110B;
	text-decoration: underline;
}
img {
	border: 0px;
}
#header p {
	font-size:18px;
	font-style:italic;
	color:#FFFFFF;
	font-family: "Georgia";
}
#header p.more {
	padding-right: 22px;
}
#nav {
	width: 740px;
	height: 48px;
	margin: 0px 0px 0px 20px;
	background-color: #c23315;
	border-radius: 10px;
	margin-top: 0px;
	float: left;
	text-align: center;
	background-repeat:no-repeat;
	display:inline;
	float:left;

}
#nav a {
	font-size: 18px;
	font-style: italic;
	font-family: "Georgia";
	margin: 12px 0px 10px 0px;
	padding: 0px 20px 0px 20px;
	display:inline;
	float:left;
	border-right-width: 2px;
	border-right-style: inset;
	color: black;
}

f#nav a:hover {
	color:#862e06;
	text-decoration:none;
}

.lastchild {
	border-right: none 0px
}

#body {
	clear: both;
	width: 100%;
}
#body-bot {
	background: bottom url(images/foot_stretch.gif)no-repeat;
	padding-top: 20px;
	border: 10px;
	padding: 21px 25px 15px 42px;
}
#about-box {
	float: left;
	width: 315px;
}
#about-box ul {
	margin-left: 8px;
}
#express-box {
	float: right;
	width: 327px;
}
#foot {
	width: 738px;
	margin-left: 20px;
}
#foot-top {
	background:url(images/foot_top.gif)no-repeat;
}
#foot-bot {
	background:url(images/foot_bot.gif)no-repeat;
	padding: 13px 21px 12px 28px;
}
#what-box {
	float: left;
	width: 332px;
}
#what-box img.left {
	margin-left: 10px;
}
#what-box ul {
	float: left;
	margin-left: 2px;
	width: 184px;
}
#news-box {
	float: right;
	width: 316px;
}
#news-box ul {
	float: left;
	margin-left: 2px;
	width: 184px;
}
#footer {
	margin: 14px;
	text-align: center;
	font-weight: bold;
	color: black;
}
h2 {
	margin: 0px;
	padding: 0px 0px 10px 0px;
	font-family: "Georgia";
	font-size:20px;
	font-style:italic;

	color:#862e06;
}
h2 b{
	color:#341c12;
}

ul {
	margin: 0px;
	padding: 0px;
}
li {
	margin: 0px;
	padding: 0px 0px 5px 20px;
	list-style: none;
	background: 0px 3px url(images/bullet.gif) no-repeat;
}
p {
	margin-top: 0px;
	margin-bottom: 10px;
}
div.narrow-text {
	margin-right: 18px;
}
img.left {
	float: left;
	padding-right: 14px;
	padding-bottom: 16px;
}
#body p.more {
	padding-top: 6px;
}
#news-box p.more {
	padding-top: 0px;
	margin-top: 0px;
}
p.more {
	text-align: right;
}
.clear {
	clear: both;
}
td {
	text-align: right;
}

table {
  font-family: Georgia,;
  border-collapse: separate;
  width: 70%;
  
}

td, th {
  border: 1px solid #dddddd;
  text-align:
  padding: 8px;
  box-shadow: 1px 2px grey;
  margin-right:revert;
}

tr:nth-child(even) {
  background-color: #F0D1C3;
}

tr:nth-child(odd) {
	background-color: white;
}

	
	</style>
</head>



		<label>Search our Site</label>
		<input type="text" name="txt1">


<div id="wrapper">
	<div id="header">
	  <div>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
	  </div>
	</div>
	<div id="nav"> <a href="#">Home</a> <a href="#">About us</a> <a href="#">Services</a> <a href="#">Music</a> <a href="#">Courses</a> <a class="lastchild" href="#">Contact us</a></div>
	<div id="body">
	  <div id="body-top">
		<div id="body-bot">
		  <div id="about-box">
			<h2><b>About</b> our music</h2>
			<img src="images/pic_1.jpg" alt="Pic 1" class="left" width="112" height="92">
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
			</p>
			<ul>
			  <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </li>
			  <li>Cras sem

<details>
<summary>英文:</summary>

I am stumped. I need help making my code look like the screenshot provided. I am using Microsoft Visual Code.

Correct Screenshot I need my code to look like

![](https://i.stack.imgur.com/OHsJK.png)

This is what my current screen looks like

![](https://i.stack.imgur.com/2Zsnk.jpg)

&lt;!-- begin snippet: js hide: false console: true babel: false --&gt;

&lt;!-- language: lang-html --&gt;

    &lt;!DOCTYPE html&gt;

    &lt;html lang=&quot;zxx&quot;&gt;
    &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
    &lt;title&gt;College of Music&lt;/title&gt;

    &lt;style&gt;
    		
    	/* Hex Colors: #CDC2B3, #5F3E2F, #C23315, #341C12, #D8B9AB, #862E06, #F0D1C3 */
    	
    	* {margin: 0; padding: 0}


    #wrapper {
    	width: 778px;
        margin: auto;
    	text-align: left;
    }
    #header {
    	height:320px;
    	background: url(images/header.jpg)no-repeat;
    		
    }
    #header div {
    	padding: 183px 213px 0px 82px;
    }
    #header p {
    	margin: 0px;
    	padding: 0px;
    }

    #header a {
    	color:#FFFFFF;
    }
    body {
    	background: #cdc2b3;
    	text-align: center;
    	margin: 0px;
    	padding: 20px 0px 20px 0px;
    	font: 15px &quot;Georgia&quot;; 
    	color: #5F3E2F;
    }
    a {
    	color: #5F3E2F;
    	font-weight: bold;
    	text-decoration: none;
    }
    a:hover {
    	color: #1D110B;
    	text-decoration: underline;
    }
    img {
    	border: 0px;
    }
    #header p {
    	font-size:18px;
    	font-style:italic;
    	color:#FFFFFF;
    	font-family: &quot;Georgia&quot;;
    }
    #header p.more {
    	padding-right: 22px;
    }
    #nav {
    	width: 740px;
    	height: 48px;
    	margin: 0px 0px 0px 20px;
    	background-color: #c23315;
    	border-radius: 10px;
    	margin-top: 0px;
    	float: left;
    	text-align: center;
    	background-repeat:no-repeat;
    	display:inline;
    	float:left;

    }
    #nav a {
    	font-size: 18px;
    	font-style: italic;
    	font-family: &quot;Georgia&quot;;
    	margin: 12px 0px 10px 0px;
    	padding: 0px 20px 0px 20px;
    	display:inline;
    	float:left;
    	border-right-width: 2px;
    	border-right-style: inset;
    	color: black;
    }

    f#nav a:hover {
    	color:#862e06;
    	text-decoration:none;
    }

    .lastchild {
    	border-right: none 0px
    }

    #body {
    	clear: both;
    	width: 100%;
    }
    #body-bot {
    	background: bottom url(images/foot_stretch.gif)no-repeat;
    	padding-top: 20px;
    	border: 10px;
    	padding: 21px 25px 15px 42px;
    }
    #about-box {
    	float: left;
    	width: 315px;
    }
    #about-box ul {
    	margin-left: 8px;
    }
    #express-box {
    	float: right;
    	width: 327px;
    }
    #foot {
    	width: 738px;
    	margin-left: 20px;
    }
    #foot-top {
    	background:url(images/foot_top.gif)no-repeat;
    }
    #foot-bot {
    	background:url(images/foot_bot.gif)no-repeat;
    	padding: 13px 21px 12px 28px;
    }
    #what-box {
    	float: left;
    	width: 332px;
    }
    #what-box img.left {
    	margin-left: 10px;
    }
    #what-box ul {
    	float: left;
    	margin-left: 2px;
    	width: 184px;
    }
    #news-box {
    	float: right;
    	width: 316px;
    }
    #news-box ul {
    	float: left;
    	margin-left: 2px;
    	width: 184px;
    }
    #footer {
    	margin: 14px;
    	text-align: center;
    	font-weight: bold;
    	color: black;
    }
    h2 {
    	margin: 0px;
    	padding: 0px 0px 10px 0px;
    	font-family: &quot;Georgia&quot;;
    	font-size:20px;
    	font-style:italic;

    	color:#862e06;
    }
    h2 b{
    	color:#341c12;
    }

    ul {
    	margin: 0px;
    	padding: 0px;
    }
    li {
    	margin: 0px;
    	padding: 0px 0px 5px 20px;
    	list-style: none;
    	background: 0px 3px url(images/bullet.gif) no-repeat;
    }
    p {
    	margin-top: 0px;
    	margin-bottom: 10px;
    }
    div.narrow-text {
    	margin-right: 18px;
    }
    img.left {
    	float: left;
    	padding-right: 14px;
    	padding-bottom: 16px;
    }
    #body p.more {
    	padding-top: 6px;
    }
    #news-box p.more {
    	padding-top: 0px;
    	margin-top: 0px;
    }
    p.more {
    	text-align: right;
    }
    .clear {
    	clear: both;
    }
    td {
    	text-align: right;
    }

    table {
      font-family: Georgia,;
      border-collapse: separate;
      width: 70%;
      
    }

    td, th {
      border: 1px solid #dddddd;
      text-align:
      padding: 8px;
      box-shadow: 1px 2px grey;
      margin-right:revert;
    }

    tr:nth-child(even) {
      background-color: #F0D1C3;
    }

    tr:nth-child(odd) {
    	background-color: white;
    }

    	
    	&lt;/style&gt;
    &lt;/head&gt;



    		&lt;label&gt;Search our Site&lt;/label&gt;
    		&lt;input type=&quot;text&quot; name=&quot;txt1&quot;&gt;


    &lt;div id=&quot;wrapper&quot;&gt;
    	&lt;div id=&quot;header&quot;&gt;
    	  &lt;div&gt;
    		&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
    	  &lt;/div&gt;
    	&lt;/div&gt;
    	&lt;div id=&quot;nav&quot;&gt; &lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;About us&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;Services&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;Music&lt;/a&gt; &lt;a href=&quot;#&quot;&gt;Courses&lt;/a&gt; &lt;a class=&quot;lastchild&quot; href=&quot;#&quot;&gt;Contact us&lt;/a&gt;&lt;/div&gt;
    	&lt;div id=&quot;body&quot;&gt;
    	  &lt;div id=&quot;body-top&quot;&gt;
    		&lt;div id=&quot;body-bot&quot;&gt;
    		  &lt;div id=&quot;about-box&quot;&gt;
    			&lt;h2&gt;&lt;b&gt;About&lt;/b&gt; our music&lt;/h2&gt;
    			&lt;img src=&quot;images/pic_1.jpg&quot; alt=&quot;Pic 1&quot; class=&quot;left&quot; width=&quot;112&quot; height=&quot;92&quot;&gt;
    			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&lt;/p&gt;
    			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
    			&lt;/p&gt;
    			&lt;ul&gt;
    			  &lt;li&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. &lt;/li&gt;
    			  &lt;li&gt;Cras semper erat ut mi. &lt;/li&gt;
    			  &lt;li&gt;Proin lobortis ipsum ac erat. &lt;/li&gt;
    			  &lt;li&gt;Morbi nec enim vitae est posuere luctus.&lt;/li&gt;
    			&lt;/ul&gt;
    		  &lt;/div&gt;
    		  &lt;div id=&quot;express-box&quot;&gt;
    			&lt;h2&gt;&lt;b&gt;About&lt;/b&gt; our staff&lt;/h2&gt;
    			&lt;img src=&quot;images/pic_2.jpg&quot; alt=&quot;Pic 2&quot; class=&quot;left&quot; width=&quot;112&quot; height=&quot;92&quot;&gt;
    			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
    			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
    			&lt;div class=&quot;narrow-text&quot;&gt;
    			  &lt;p&gt;Our staff all received special training from former American Idol judges!&lt;/p&gt;
    			
    			&lt;/div&gt;
    			
    		  &lt;/div&gt;
    		  &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    		&lt;/div&gt;
    	  &lt;/div&gt;
    	&lt;/div&gt;
    	&lt;div id=&quot;foot&quot;&gt;
    	  &lt;div id=&quot;foot-top&quot;&gt;
    		&lt;div id=&quot;foot-bot&quot;&gt;
    		  &lt;div id=&quot;what-box&quot;&gt;
    	&lt;table&gt;
    			&lt;td class=&quot;header&quot; colspan=&quot;2&quot;&gt;
    				&lt;h2&gt;&lt;b&gt;What&lt;/b&gt; we offer&lt;/h2&gt;
    				&lt;table&gt;
      
    					&lt;tr&gt;
    					  
    					  
    					&lt;/tr&gt;
    					&lt;tr&gt;
    					  &lt;td&gt;Advanced Banjo&lt;/td&gt;
    					  &lt;td&gt;10,000 Bitcoins&lt;/td&gt;
    					  
    					&lt;/tr&gt;
    					&lt;tr&gt;
    					  &lt;td&gt;Beginner Washboard&lt;/td&gt;
    					  &lt;td&gt;6000 Bitcoins&lt;/td&gt;
    					  
    					&lt;/tr&gt;
    					&lt;tr&gt;
    					  &lt;td&gt;Whacking Paintbucktes&lt;/td&gt;
    					  &lt;td&gt;20,000 Bitcoins&lt;/td&gt;
    					  
    					&lt;/tr&gt;
    					&lt;tr&gt;
    					  &lt;td&gt;Humming Annoyingly&lt;/td&gt;
    					  &lt;td&gt;50,000 Bitcoins&lt;/td&gt;
    					  
    					&lt;/tr&gt;
    					
    				  &lt;/table&gt;
    			
    		  &lt;/div&gt;
    		  &lt;div id=&quot;news-box&quot;&gt;
    			&lt;h2&gt;&lt;b&gt;News&lt;/b&gt; &amp;amp; events&lt;/h2&gt;
    			&lt;img src=&quot;images/pic_4.jpg&quot; alt=&quot;Pic 4&quot; class=&quot;left&quot; width=&quot;86&quot; height=&quot;77&quot;&gt;
    			&lt;ul&gt;
    			  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Nullam&lt;/a&gt; scelerisque consequat libero. &lt;/li&gt;
    			  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Vivamus&lt;/a&gt; mattis augue ut augue.&lt;/li&gt;
    			&lt;/ul&gt;
    			
    		  &lt;/div&gt;
    		  &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
    		&lt;/div&gt;
    	  &lt;/div&gt;
    	&lt;/div&gt;
    	&lt;div id=&quot;footer&quot;&gt;
    	  &lt;p&gt;&#169; 2019 collegeofmusic.com all right reserved - Designed by Keebler Elves&lt;/p&gt;
    	&lt;/div&gt;
      &lt;/div&gt;
      &lt;/html&gt;

&lt;!-- end snippet --&gt;

When I added the table to &quot;What we offer / News &amp; Events&quot; my table background went white and my footer box went away. Now they are stacked on top of each other. My top box where my &quot;About our Music / About Our Staff&quot; won&#39;t show up. My background color sits on top of the box. I am trying to make my code look like the &quot;Correct Screenshot&quot;. 

</details>


# 答案1
**得分**: 1

Your HTML is not valid.
You can test it here, for example: https://validator.w3.org/nu/#textarea
I marked it with comments in the following code block.

```html
<div id="foot">
  <div id="foot-top">
    <div id="foot-bot">
      <div id="what-box">
        <table><!-- This element is not closed, and the "tr" is missing -->
          <td class="header" colspan="2"><!-- This element is not closed -->
            <h2><b>What</b> we offer</h2>
            <table>
              <tr><!-- This element must contain "td" -->
                
                
              </tr>
              <tr>
                <td>Advanced Banjo</td>
                <td>10,000 Bitcoins</td>
              </tr>
              <tr>
                <td>Beginner Washboard</td>
                <td>6000 Bitcoins</td>
              </tr>
              <tr>
                <td>Whacking Paintbuckets</td>
                <td>20,000 Bitcoins</td>
              </tr>
              <tr>
                <td>Humming Annoyingly</td>
                <td>50,000 Bitcoins</td>
              </tr>
            </table>
          </td>
        </table>
      </div>
    </div>
  </div>
</div>

(Note: I've added HTML tags to your code to make it more readable.)

英文:

Your HTML is not valid.
You can test it here for example: https://validator.w3.org/nu/#textarea
I marked it with comments in the following code block.

&lt;div id=&quot;foot&quot;&gt;
&lt;div id=&quot;foot-top&quot;&gt;
&lt;div id=&quot;foot-bot&quot;&gt;
&lt;div id=&quot;what-box&quot;&gt;
&lt;table&gt;&lt;!-- This element is not closed and the &quot;tr&quot; is missing --&gt;
&lt;td class=&quot;header&quot; colspan=&quot;2&quot;&gt;&lt;!-- This element is not closed --&gt;
&lt;h2&gt;&lt;b&gt;What&lt;/b&gt; we offer&lt;/h2&gt;
&lt;table&gt;
&lt;tr&gt;&lt;!-- This element must contain &quot;td&quot; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Advanced Banjo&lt;/td&gt;
&lt;td&gt;10,000 Bitcoins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Beginner Washboard&lt;/td&gt;
&lt;td&gt;6000 Bitcoins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Whacking Paintbucktes&lt;/td&gt;
&lt;td&gt;20,000 Bitcoins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Humming Annoyingly&lt;/td&gt;
&lt;td&gt;50,000 Bitcoins&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;

huangapple
  • 本文由 发表于 2023年5月7日 07:43:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76191654.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定