search
HomeWeb Front-endHTML Tutorialcss style setting issues, two questions_html/css_WEB-ITnose

问题1:
如何让li适应嵌套在他里面的内容的高度...

<div style="width=100%;float:left;"> <ul id="ShowLists">    <li >    <div class="tips">班级信息:</div><div class="MainInfo">终极一班</div><br />    <div class="tips">班级信息:</div><div class="MainInfo">终极一班</div><br />    <div class="tips">班级信息:</div><div class="MainInfo">终极一班</div>    </li><li >    <div class="tips">班级信息:</div><div class="MainInfo">终极2班</div><br />    <div class="tips">班级信息:</div><div class="MainInfo">终极2班</div><br />    <div class="tips">班级信息:</div><div class="MainInfo">终极2班</div>    </li><ul>

里面的,li貌似是固定的,不会随着嵌套的div而改变...
下面是我的样式
/*列表项---该列表用于显示用户的简略信息,通常是三行*/    ul{ border-left:1px solid #BEBEBE;border-right:1px solid #BEBEBE; border-radius:10px;padding:0px; overflow:hidden; }ul li{  list-style:none;padding:0px; border-bottom:1px solid #BEBEBE; padding-top:5px; height:auto;  background :url(../AppImages/right.png) no-repeat scroll right center transparent;}

这样写得效果直接就是
那中间两条线 应该就是li得底边框,它高度固定了...
Li的高度不能固定,因为你不知道动态读出来的玩意有多少行...

问题二:div点击高亮效果怎么做,是针对手机web的,当触碰的时候高亮,手指离开的时候恢复...有插件?


回复讨论(解决方案)

li{
    overflow:hidden;
}



2)写js绑定事件  touchstart 手摸上去触发   touchend 手拿开触发 在事件里面设置下class

能说下你在li中加div的目的是什么吗?

li{
    overflow:hidden;
}



2)写js绑定事件  touchstart 手摸上去触发   touchend 手拿开触发 在事件里面设置下class



   overflow:hidden;溢出的东西就隐藏了

能说下你在li中加div的目的是什么吗?



不用div 用 span也是一样的,li都不会自动适应

不管用div 或者span 我只是在给字体加个样式而已 前面的div 字体是粗体....后面的div 点击高亮,带图片,有的带颜色,,,

你在div里用两个span来控制下试试 . 我用li的话右边内容也会被挤下去 , 用span解决了这类问题.


li{
    overflow:hidden;
}



2)写js绑定事件  touchstart 手摸上去触发   touchend 手拿开触发 在事件里面设置下class



   overflow:hidden;溢出的东西就隐藏了

li里面div的样式写出来看看



li{
    overflow:hidden;
}



2)写js绑定事件  touchstart 手摸上去触发   touchend 手拿开触发 在事件里面设置下class



   overflow:hidden;溢出的东西就隐藏了

li里面div的样式写出来看看


.tips{   display:block; float:left; width:97px; font-weight:bold;  text-align:left; height:30px; line-height:30px;  text-overflow: ellipsis; }.MainInfo{   display:block; float:left; width:70%; font-weight:normal;  text-align:left;height:30px;line-height:30px;  text-overflow: ellipsis;    background :url(../AppImages/edit.png) no-repeat scroll right center transparent;}

我才看见 你结构不对
你里面用 
干嘛

是用在 行内元素中的换行 


        

  •           

                     
    • 班级信息:
      终极一班

    •               
    • 班级信息:
      终极一班

    •              
    • 班级信息:
      终极一班

    •                                          

      It is used for line breaks in inline elements
      •                                                                                                                                                                                                                    

      • Class information:
        Ultimate Class 1

      •                                                                                                                    ;li>
        Class information:
        Ultimate Class 1

  •     ul>
                                                     There is no br in front... It is made with , is an inline element... Because the two types of tips use pixels, and MainInfo uses percentages. It is displayed on the computer screen and has a much wider width. I just added a br. . Later, I thought span was inline, so Li was highly invalid. I changed the tips and MainInfo to display:block; later I found that it didn't work, so I tried div again.. and found that it didn't work either, so I posted it and asked, the code It hasn’t changed...
    It’s not possible without br now

    The height of li will change with the size of the content. I can't see all of your code and can't figure out what's wrong.
    You can add borders to li, div and other elements for debugging


    The height of li will change with the size of the content. I can't see all of your code and can't figure out what's wrong.
    You can add borders to li, div and other elements for debugging

    You are right. The height of li will change with the size of the content. I will use jq to test it. Click this li's $(this).html(); was found to be correct
    But if you add a border, it seems that the border will not change with li. Later, I didn't want the border of li, I used the border of div I found it didn’t work


    Now I switched to table, I’m really speechless

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Why are HTML tags important for web development?Why are HTML tags important for web development?May 02, 2025 am 12:03 AM

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

Explain the importance of using consistent coding style for HTML tags and attributes.Explain the importance of using consistent coding style for HTML tags and attributes.May 01, 2025 am 12:01 AM

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

How to implement multi-project carousel in Bootstrap 4?How to implement multi-project carousel in Bootstrap 4?Apr 30, 2025 pm 03:24 PM

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How does deepseek official website achieve the effect of penetrating mouse scroll event?How does deepseek official website achieve the effect of penetrating mouse scroll event?Apr 30, 2025 pm 03:21 PM

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

How to modify the playback control style of HTML videoHow to modify the playback control style of HTML videoApr 30, 2025 pm 03:18 PM

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

What problems will be caused by using native select on your phone?What problems will be caused by using native select on your phone?Apr 30, 2025 pm 03:15 PM

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone?What are the disadvantages of using native select on your phone?Apr 30, 2025 pm 03:12 PM

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...

How to optimize collision handling of third-person roaming in a room using Three.js and Octree?How to optimize collision handling of third-person roaming in a room using Three.js and Octree?Apr 30, 2025 pm 03:09 PM

Use Three.js and Octree to optimize collision handling of third-person roaming in the room. Use Octree in Three.js to implement third-person roaming in the room and add collisions...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools