请老师过目,指出不足之处,谢谢!

来源:2-5 编程练习

WYDWYD008

2017-11-03 17:28:26

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

<title>IMOOC</title>

<link rel="stylesheet" type="text/css" href="main.css">

<style>

   *{margin:0;padding:0;border:none;font-size:14px;font-family: Arial;}

        section{width:1200px;margin:0 auto;padding:15px;}

        section h1{font-size:26px;font-weight: lighter;margin-bottom:30px;}

        section h1 samp{font-size:26px;font-weight:lighter;color:#7C7C7C;}

        section > aside {width:450px;float:left;}

        section > aside > dl{position: relative;display: block; height: 74px; margin-bottom: 17px;}

        section > aside > dl dt{background:url(http://climg.mukewang.com/582e61290001787900500051.png) no-repeat;width:50px;height:50px;line-height:50px;color:#fff;text-align:center;position: absolute;left:20px;}

        section > aside > dl dd:first-of-type{position:absolute;left:88px;top:-1px;font-weight:bold;text-decoration:underline; }

        section > aside > dl dd:last-of-type{position:absolute;left:87px;top:16px;width:330px;}

        section > article{float:right;width:720px;}

        section > article p,section > article img{margin-bottom:15px;width:100%;}

</style>

</head>

<body>

<section>

   <aside>

       <h1>Recent <samp>Course</samp></h1>

         <dl>

             <dt>1</dt>

             <dd>Title 1</dd>

             <dd>test sadfjklsda  hello asdlkfj afjds aasdfasdfasdfasdfasdfasasdfasdfasdfasdfasdfasdfasdfas dfasdfasdfasdfasdfasdfasdfasdfsdf asdf 234234</dd>

         </dl>

         <dl>

             <dt>2</dt>

             <dd>Title 2</dd>

             <dd>test sadfjklsda  hello asdlkfj afjds <br>asdfkjlasfldj1123</dd>

         </dl>

         <dl>

             <dt>3</dt>

            <dd>Title 3</dd>

             <dd>test sadfjklsda  hello asdlkfj afjds <br>asdfkjlasfldj1123</dd>

         </dl>

         <dl>

             <dt>4</dt>

             <dd>Title 4</dd>

             <dd>test sadfjklsda  hello asdlkfj afjds <br>asdfkjlasfldj1123</dd>

         </dl>

   </aside>

   <article>

       <h1>Welcome to <samp>Massive Open Online Course!</samp></h1>

       <p>We provide the latest knowledge to help you cope with the changing world!</p>

   <img src="http://climg.mukewang.com/582e61180001ede703300130.jpg">

   <p>We hope that all the students who love the Internet can be more convenient access to learning resources, using the Internet thinking to change our learning.</p>

   <p>Focus on IT skills education MOOC, consistent with the development trend of the Internet down to earth's MOOC. We are free, we only teach useful, we concentrate on education.</p>

   </article>

</section>

</body>

</html>

请老师指出不足之处,谢谢

并且我还有问题就是如果第二个dd的内容多了高度就会不自适应,请问如果让dd高度自适应?谢谢

写回答

5回答

嘘_别说话

2017-11-09

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8" />
   <title>Document</title>
   <style>
       .big{background-color:red;height:400px;}
       .son1{float:left;width:40%;}
       .son1 div{background-color:yellow;margin-top:20px;}
       .son2{float:right;background-color:green;width:40%;}

   </style>
</head>
<body>
<div class="big">
   <div class="son1">
       <div>12345555555555</div>
       <div>12345555555555</div>
       <div>12345555555555</div>
       <div>12345555555555</div>
   </div>
   <div class="son2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore, consequatur porro consequuntur ad maiores obcaecati similique aliquam velit quasi, odio, sequi excepturi, dolorem fugit saepe iusto reprehenderit nam dicta. Qui!</div>
</div>
</body>
</html>

我写了demo,看看是不是你要的效果,左侧的div就没有设置高度。

不知道你为什么对不设置高度这么执着


0
hYDWYD008
h 非常感谢!
h017-11-13
共3条回复

小丸子爱吃菜

2017-11-06

可以尝试把高度设置的大一些,dl的高度就那么大,所以里面的内容一旦超出了,就会覆盖后面的内容;

也可以给文字所在区域的元素设置overflow:hidden;这样即使内容多出来了,也不会覆盖下面的内容,但是超出的内容会被隐藏掉。

要么就不设置固定的高度,让内容自己去撑开。

0
hYDWYD008
h 感谢老师的回答,但还是想麻烦请教一下老师。我就是想知道如何让高度自己撑开,不设置高度是可以让内容自己撑开。但是就像这个例子一样,我们需要绝对定位。那么必须就需要设定一个高度,不过就会出现重叠无法定位。请老师就以这个例子告诉我一下,这种情况如果让内容自己撑开高度。感谢,感谢!
h017-11-08
共1条回复

WYDWYD008

提问者

2017-11-06

http://img.mukewang.com/climg/5a0011350001637504790203.jpg

请老师看,就是这个问题,不是不能换行,是高度没有撑开导致内容多了会重叠到下面的文字上面了。请问这个问题在不截取字符数量的情况如何解决?

0

Miss路

2017-11-05

高度自适应不就是要文字多了换行吗?设置宽度那不教宽度自适应,自适应的意思是跟着内容的变化而变化。

0
hYDWYD008
h 文字多了是可以自动换行,但是如果文字太多了,高度撑不开。多出来的文字会覆盖到下面一个DL上面去,我想知道这个怎么解决,谢谢。这个回复无法截图,我把问题效果截图到回答里面了请老师看看,谢谢
h017-11-06
共1条回复

Miss路

2017-11-03

代码写的倒是非常整洁,但是效果和要求有点差距,你再看一下原型图,左边的和右边的内容是底部对齐的,可以再调整一下。

关于说dd不能自适应的问题,只要给dd设置了宽度,他就会自动换行的。

祝学习愉快!

0
hYDWYD008
h 谢谢老师,没仔细看效果图。等会在重新改一下。关于dd我的问题不是宽度自适应,我是想问高度如何自适应?设置宽度文字多了是会自己掉下来,但如果在多了高度不会自己撑开请问如何解决,谢谢
h017-11-05
共1条回复

0 学习 · 5760 问题

查看课程