并排显示两个div内联

时间:2015-06-24 08:29:42

标签: html css

我正试图使用​​inline-block并排两个div。

但由于某种原因,它不会起作用。有了这个,我有两个问题:

  1. 如何在<nav><article>容器旁边并排显示内联块。导航将在左侧浮动,而文章将浮动在右侧。我怎样才能使用display: inline-block。我不需要float

  2. 如何更改ul li ul li的列表样式并修复其缩进的位置,如下所示:http://prntscr.com/7koc47

  3. 这是我的CSS:

    /* http://meyerweb.com/eric/tools/css/reset/ 
       v2.0 | 20110126
       License: none (public domain)
    */
    
    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed, 
    figure, figcaption, footer, header, hgroup, 
    menu, nav, output, ruby, section, summary,
    time, mark, audio, video {
    	margin: 0;
    	padding: 0;
    	border: 0;
    	font-size: 100%;
    	font: inherit;
    	vertical-align: baseline;
    }
    /* HTML5 display-role reset for older browsers */
    article, aside, details, figcaption, figure, 
    footer, header, hgroup, menu, nav, section {
    	display: block;
    }
    body {
    	line-height: 1;
    }
    ol, ul {
    	list-style: none;
    }
    blockquote, q {
    	quotes: none;
    }
    blockquote:before, blockquote:after,
    q:before, q:after {
    	content: '';
    	content: none;
    }
    table {
    	border-collapse: collapse;
    	border-spacing: 0;
    }
    
    
    /* General CSS */
    
    body{
    	background-color: #eeeeee;
    	font-family: "Times New Roman", Georgia, Serif;
    	font-size: 17px;
    }
    
    #wrapper{
    	width: 970px;
    	margin: 0 auto;
    
    }
    
    
    header{
    	background-color: #dddddd;
    	padding: 15px;
    	margin: 15px 0;
    }
    
    header h1{
    	font-size: 40px;
    	font-weight: bold;
    }
    
    nav{
    	background-color: #dddddd;
    
    }
    
    nav{
    	display: inline-block;
    }
    
    nav ul li{
    	list-style: disc;
    }
    
    nav ul > li{
    	list-style: circle;
    }
    
    nav ul li a{
    	text-decoration: none;
    }
    
    
    
    article{
    	display: inline-block;
    	background-color: #aaaaaa;
    	margin: 20px 0;
    }
    
    
    article h2{
    	font-size: 30px;
    	font-weight: bold;
    	margin: 20px 0;
    }
    
    
    article ul li{
    	list-style: disc;
    	margin: 15px 0;
    }
    
    article ul li a{
    	font-weight: bold;
    
    }
    
    footer{
    	background-color: #dddddd;
    	margin: 15px 0;
    }
    
    .border{
    	-webkit-border-radius: 25px;
    	-moz-border-radius: 25px;
    	border-radius: 25px;
    	padding: 25px;
    }
    <div id="wrapper">
    
    <header class="border">
    <h1>@ Loup's</h1>
    </header>
    
    <nav id="links" class="border">
        <ul>
            <li><a href="#">Home</a>
            <ul> 
            <li><a href="#">articles/</a>
            <ul>
                <li><a href="#">beliefs respect and facts</a></li>
                <li><a href="#">classes suck</a></li>
                <li><a href="#">taboo oo</a></li>
                <li><a href="#">classes as syntatic sugar</a></li>
                <li><a href="#">syntatic sugar</a></li>
                <li><a href="#">better keyboards</a></li>
                <li><a href="#">ideal computer</a></li>
                <li><a href="#">assignment</a></li>
                <li><a href="#">language</a></li>
                <li><a href="#">dcvs</a></li>
                <li><a href="#">is fp feasible</a></li>
                <li><a href="#">does oo sucks</a></li>
            </ul>
            </li>
        
    
            <li><a href="#">projects</a></li>
            <li><a href="#">tutorials</a></li>
            <li><a href="#">contact me</a></li>
        </ul>
    </nav>  
    
    <article class="border">
    <h2>My essays</h2>
    <p>My last posts depend on each other, and should be read in sequence. Articles not in bold are optionnal.</p>
    
    <ul>
        <li><a href="#">Assignment Statement Considered Harmfull</a>. Pervasive mutable state mate programs more difficult to deal with. While this is old news, most programmers don't know or don't care. It's a pitty, because <a href="#">simple remedies</a> exist.</li>
    
        <li><a href="#">Defining Syntatic Sugar</a>. I sometimes hear arguments about what is or is not syntactic sugar. This is an attempt at defining it. </li>
    
        <li><a href="#">Class-based Programming as Syntactic Sugar</a>. Most of the time, "Object Oriented" actually mean classes. Classes are nothing more than syntactic sugar, at least in statically typed languages such as Java and C++. Sugar is not useless, but seeing past it helps us understand classes better.</li>
    
        <li><a href="#">Taboo "OO"</a>. The term "OO" is so overloaded that we should stop using it. Better substitutes are "classes" and "prototypes".</li>
    
    
        <li><a href="#">How Class based Programming Sucks</a>. Classes are vastly sub-optimal. Functional programming is far better.</li>
    </ul>
    </article>
    
    
    <footer class="border">
        <p>Contact, suggestions: Send me an email at <a href="#">l@loup-valliant.fr</a></p>
        <p>Built with <a href="#">USSM</a></p>
    </footer>

    在这里查看我的JSFIDDLE:https://jsfiddle.net/yshckr8a/

3 个答案:

答案 0 :(得分:1)

要在导航栏旁边显示您的文章,您只需要为文章设置宽度:

article {
   width: 70%;
}

要移动子ul li,只需在其上添加边距:

#links > ul > li > ul > li > ul > li {
    margin-left: 20px;
}

对于您的列表样式:

#links > ul > li > ul > li {
  list-style-type: initial;
}
#links > ul > li > ul > li > ul > li {
  list-style: outside none circle;
}
#links > ul > li {
  list-style-type: none;
}

更新的JSfiddle:https://jsfiddle.net/ghorg12110/yshckr8a/3/

答案 1 :(得分:1)

这是你的CSS:

nav{
    display: inline-block;
}
nav ul:first-child > li:first-child {
    list-style: none;
}
nav ul:first-child > li:first-child > a{
    position: relative;
    left: -20px;
}
nav > ul > li > ul > li {
    list-style: disc !important;
}

nav ul ul > li{
    list-style: circle !important;
    padding-left: 10px;
}


nav ul li a{
    text-decoration: none;
}

答案 2 :(得分:0)

1

两个width未并排排列的原因是它们没有足够的空间,为了证明您可以在文章中添加div's 并使article垂直对齐到顶部。

我建议您尽可能使用navnav { vertical-align: top; width: 20%; } article { vertical-align: top; width: 69%; }

的百分比
margin-left

2

对于第二个问题,只需将ul添加到ul { margin-left: 10px }

即可
SELECT
    yesnoFieldName,
    Count(someField)
FROM
    yourTableName
GROUP BY 
    yesnoFieldName;

jsFiddle