如何制作浮动div和相等的高度(How to make floating divs and equal height)
首先,这是我的网页代码
@import url("reset.css"); @import url('https://fonts.googleapis.com/css?family=Raleway'); * { box-sizing:border-box; } body { background-color: #9E9E9E; } #wrapper { width:95%; max-width:980px; margin: 0 auto; font-family: 'Raleway', sans-serif; line-height: 2rem; } .header { padding:18px; background-color: #757575; border-radius:5px; width:100%; margin-top:5px; margin-bottom:5px; } .column_left { float:left; padding:18px; width:70% ; background-color:#607D8B; border-top-left-radius: 5px; border-bottom-left-radius:5px; } .column_right { float:right; padding:18px; width:29.99%; background-color:#455A64; border-top-right-radius: 5px; border-bottom-right-radius: 5px; } /*For Screens 750 PX or less (width)*/ @media screen and (max-width:750px) { .header { text-align:center; } .column_right { display:none; } .column_left { width:100%; border-radius:5px; } } h1 { font-size:1.8rem; } h2 { font-size: 1.4rem; } p { } nav {} nav ul {} nav ul li { width:100%; background-color:#607D8B; text-align:center; padding:2.5px; border-radius:5px; margin-bottom:5px; } nav ul li a { color:#455A64; } footer { padding:18px; background-color: #757575; border-radius:5px; width:100%; margin-top:5px; margin-bottom:5px; float:none; display:flex; }
<meta name="viewport" content="width=device-width, user-scalable=no"> <div id="wrapper"> <h1 class="header">Lorem Ipsum</h1> <div class="column_left"> <h2>Welcome to Lorem Ipsum</h2> <p>Aenean nec vestibulum justo, ut aliquet ante. </p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <p>Etiam viverra interdum neque, sed sagittis lectus sodales sit amet.</p> <p>Maecenas posuere laoreet auctor. Integer vel nulla ut magna interdum consectetur.</p> <p>Vestibulum non ligula sed diam luctus tincidunt in sit amet metus.</p> </div> <div class="column_right"> <h2>Navigation</h2> <nav> <ul> <li><a class="button" href="#">Link</a></li> <li><a class="button" href="#">Link</a></li> <li><a class="button" href="#">Link</a></li> </ul> </nav> </div> <footer> © 2016 Ipsum Lorem </footer> </div>
基本上我想让
column_left
和column_right
类具有相同的高度,而不使用height=100%
。 该网站将有多个页面,其他页面的长度可能与示例页面不同。 这是我到目前为止的图像:基本上,我希望导航div与旁边的导航div一样高。
First of all, this is my code for the web page
@import url("reset.css"); @import url('https://fonts.googleapis.com/css?family=Raleway'); * { box-sizing:border-box; } body { background-color: #9E9E9E; } #wrapper { width:95%; max-width:980px; margin: 0 auto; font-family: 'Raleway', sans-serif; line-height: 2rem; } .header { padding:18px; background-color: #757575; border-radius:5px; width:100%; margin-top:5px; margin-bottom:5px; } .column_left { float:left; padding:18px; width:70% ; background-color:#607D8B; border-top-left-radius: 5px; border-bottom-left-radius:5px; } .column_right { float:right; padding:18px; width:29.99%; background-color:#455A64; border-top-right-radius: 5px; border-bottom-right-radius: 5px; } /*For Screens 750 PX or less (width)*/ @media screen and (max-width:750px) { .header { text-align:center; } .column_right { display:none; } .column_left { width:100%; border-radius:5px; } } h1 { font-size:1.8rem; } h2 { font-size: 1.4rem; } p { } nav {} nav ul {} nav ul li { width:100%; background-color:#607D8B; text-align:center; padding:2.5px; border-radius:5px; margin-bottom:5px; } nav ul li a { color:#455A64; } footer { padding:18px; background-color: #757575; border-radius:5px; width:100%; margin-top:5px; margin-bottom:5px; float:none; display:flex; }
<meta name="viewport" content="width=device-width, user-scalable=no"> <div id="wrapper"> <h1 class="header">Lorem Ipsum</h1> <div class="column_left"> <h2>Welcome to Lorem Ipsum</h2> <p>Aenean nec vestibulum justo, ut aliquet ante. </p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <p>Etiam viverra interdum neque, sed sagittis lectus sodales sit amet.</p> <p>Maecenas posuere laoreet auctor. Integer vel nulla ut magna interdum consectetur.</p> <p>Vestibulum non ligula sed diam luctus tincidunt in sit amet metus.</p> </div> <div class="column_right"> <h2>Navigation</h2> <nav> <ul> <li><a class="button" href="#">Link</a></li> <li><a class="button" href="#">Link</a></li> <li><a class="button" href="#">Link</a></li> </ul> </nav> </div> <footer> © 2016 Ipsum Lorem </footer> </div>
Basically I would like to have the
column_left
andcolumn_right
classes the same height, without usingheight=100%
. The website will have more than one page, and the length on the others may not be the same as the example page. Here is an image of what I got so far:Basically, I want the navigation div to be as tall as the one beside it.
原文:https://stackoverflow.com/questions/40986531
最满意答案
点表示正则表达式中的“每个字符”。 试着逃避它:
Pattern pattern = Pattern.compile("\\./\\.");
(你需要两个后退,以逃避String中的反斜杠本身,以便Java知道你想要一个反斜杠而不是一个特殊字符作为换行符,例如
\n
A dot means "every character" in regular expressions. Try to escape it:
Pattern pattern = Pattern.compile("\\./\\.");
(You need two backslahes, to escape the backslash itself inside the String, so that Java knows you want to have a backslash and not a special character as the newline character, e.g.
\n
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
如何在文本文件中的特定列位置添加或替换某些字符串(How to add or replace some string at a particular column position in a text file)[2022-09-20]
如果您的第一个字符串更改,这意味着长度,在这种情况下,切片将不起作用: 更好地使用这种方式: >>> s.split(' ') ['Roxila', 'almost', 'lost'] >>> p = s.split(' ') >>> p[0]+'*'+' '.join(p[1:]) 'Roxila*almost lost' >>> If your first string change, which means the length, in that case slicing won't work: B ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
点表示正则表达式中的“每个字符”。 试着逃避它: Pattern pattern = Pattern.compile("\\./\\."); (你需要两个后退,以逃避String中的反斜杠本身,以便Java知道你想要一个反斜杠而不是一个特殊字符作为换行符,例如\n A dot means "every character" in regular expressions. Try to escape it: Pattern pattern = Pattern.compile("\\./\\."); (Yo ...
-
如何使用java将文本文件中包含的整个字符串替换为新行?(How to replace entire string contained in a text file to new line using java?)[2022-08-26]
你可以在replaceAll则表达式如下: line = line.replaceAll("[|+-]+", "\n"); You can regex in replaceAll like this: line = line.replaceAll("[|+-]+", "\n"); -
找到该文件。 File file = new File("/path/to/file.txt"); 创建一个临时文件(否则你首先要将所有内容都读入Java的内存)。 File temp = File.createTempFile("file", ".txt", file.getParentFile()); 确定字符集。 String charset = "UTF-8"; 确定要删除的字符串。 String delete = "foo"; 打开文件进行阅读。 BufferedReader reader ...
-
一种方法是使用String.replaceAll() : File log= new File("log.txt"); String search = "textFiles/a\\.txt"; // <- changed to work with String.replaceAll() String replacement = "something/bob.txt"; //file reading FileReader fr = new FileReader(log); String s; try { ...
-
如何用Python 3替换文本文件中的所有字符串实例?(How to replace all instances of a string in text file with Python 3?)[2022-04-24]
尝试这个: # Make sure this is the valid path to your file file = input("Enter a filename: ") remove = input("Enter the string to be removed: ") # Read in the file with open(file, "r") as file: filedata = file.read() # Replace the target string filedata = ... -
将更改的行写入文本文件的中间不会起作用,除非它与原始文件的长度完全相同 - 在您的示例中就是这种情况,但是您已经有一些明显的占位符文本,因此我不知道如果您的实际应用程序代码也是如此。 这是一种不会做出这样的假设的方法: with open('filename', 'r') as f: data = f.readlines() data[1] = re.sub(groupname,aliasname, data[1]) with open('filename', 'w') as f: f.wr ...
-
如果您使用支持正则表达式搜索和替换的工具,则解决方案非常简单。 一个很好的选择是我的REPL.BAT实用程序 - 一个混合JScript /批处理脚本,它执行正则表达式搜索并替换stdin并将结果写入stdout。 它是纯粹的脚本,可以在XP前面的任何现代Windows机器上本机运行。 完整文档嵌入在脚本中。 下面的正则表达式查找以空格,2位数,01,4位数,然后是可选空格结尾的行。 它保留括号内的值(由$ 1和$ 2表示),并用25代替01。 type duepayment.txt | repl "(\s ...