首页 \ 问答 \ HTML5 / CSS3无类框架(HTML5/CSS3 classless framework)

HTML5 / CSS3无类框架(HTML5/CSS3 classless framework)

有谁知道一个简单的HTML5 / CSS3框架应用最少的格式,不需要自定义类名? 理想情况下,只需要正确布局的HTML5,并且可以用最小的灵活性定位元素,使用常见的规则,比如边栏宽度等。

使用HTML5,对自定义类名称的需求少得多,包含headernavaside元素,但我还没有看到充分利用这一点的框架。 有任何想法吗?

澄清:我经历过所有常见的嫌疑人(Bootstrap,HTML%Boilerplate,Shim等),他们都没有抓我的痒。 痒是简单的HTML5结构的简单组合,它不会假设任何关于设计的内容,而是通过一个简单的CSS3样式表来定义所有的语义,并定义了实际的布局。 我可以使用几个样式表来设想它,其中基础定义了元素的布局,并为实际设计分开了一个(s)。 它将被用作各种项目的简单起点,以后可以单独进行定制。

显然,我可能需要按照卫斯理提出的方式,自己写一个...


Does anyone know of a simple HTML5/CSS3 framework which applies a minimum of formatting with no need for custom class names? Ideally it would take only properly laid-out HTML5, and would position elements with a minimum of flexibility, using common rules for, say sidebar widths and the like.

With HTML5 there much less need for custom class names, with elements like header, nav or aside, but I haven't yet seen a framwork taking full advantage of that. Any ideas?

Clarification: I've been through all the usual suspects (Bootstrap, HTML% Boilerplate, Shim and the like), and none of them scratches my itch. And that itch is a simple combo of plain HTML5 structure which assumes nothing about the design but defines everything semantically, with a simple CSS3 stylesheet which defines the actual layout. I can envision it using several stylesheets, with a base one defining the layout of elements and separate one(s) for actual design. It would be used as a simple starting point for various projects, which could be later customized individually.

Apparently, I might need to go the way proposed by Wesley and write one myself...


原文:https://stackoverflow.com/questions/11107842
更新时间:2021-10-29 16:10

最满意答案

差异似乎是由于使用数组而不是std :: vector,我仍然很难相信。 我的两组代码如下所示,以供比较。 第一个可以从节目1以约2500MB / s的速率进行摄取。 第二个可以以3100MB / s的速率进行摄取。

计划1(2500 MB /秒)

int main(int argc, char **argv)
{
    int fd = open("/tmp/fifo2", O_RDONLY);

    std::vector<char> buf(8*1024*1024);

    while(1)
    {
       read(fd, &buf[0], 8*1024*1024);
    }
}

计划2(3100 MB /秒)

int main(int argc, char **argv)
{

    int fd = open("/tmp/fifo2", O_RDONLY);

    char buf[8*1024*1024];

    while(1)
    {
       read(fd, &buf[0], 8*1024*1024);
    }
}

两者都使用gcc版本4.4.6编译-O3。 如果任何人都可以解释这个原因,我会非常感兴趣(因为我理解std :: vector基本上是一个数组的包装)。

编辑 :我刚刚测试了下面的程序3,它可以使用ifstream并以3000 MB / s运行。 因此,使用ifstream而不是'read()'会导致性能下降很小。 比使用std :: vector的命中少得多。

计划3(3000 MB / s)

int main(int argc, char **argv)
{
    ifstream file("/tmp/fifo2", ios::in | ios::binary);

    char buf[8*1024*1024];

    while(1)
    {
       file.read(&buf[0], 32*1024);
    }
}

编辑2:

我修改了程序2的代码,以便在堆栈中使用malloc'd内存而不是内存,并且性能下降以匹配向量性能。 谢谢,ipc,为我键入了这个。


The difference appears to be due to using an array instead of std::vector, which I still have a hard time believing. My two sets of code are shown below for comparison. The first can ingest from Program 1 at a rate of about 2500 MB/s. The second can ingest at a rate of 3100 MB/s.

Program 1 (2500 MB/s)

int main(int argc, char **argv)
{
    int fd = open("/tmp/fifo2", O_RDONLY);

    std::vector<char> buf(8*1024*1024);

    while(1)
    {
       read(fd, &buf[0], 8*1024*1024);
    }
}

Program 2 (3100 MB/s)

int main(int argc, char **argv)
{

    int fd = open("/tmp/fifo2", O_RDONLY);

    char buf[8*1024*1024];

    while(1)
    {
       read(fd, &buf[0], 8*1024*1024);
    }
}

Both are compiled with -O3 using gcc version 4.4.6. If anyone can explain the reason for this I'd be very interested (since I understand std::vector to basically be a wrapper around an array).

Edit: I just tested Program 3, below, that can uses ifstream and runs at 3000 MB/s. So it appears that using ifstream instead of 'read()' incurs a very slight performance degradation. Much less than the hit taken from using std::vector.

Program 3 (3000 MB/s)

int main(int argc, char **argv)
{
    ifstream file("/tmp/fifo2", ios::in | ios::binary);

    char buf[8*1024*1024];

    while(1)
    {
       file.read(&buf[0], 32*1024);
    }
}

Edit 2:

I modded Program 2's code to use malloc'd memory instead of memory on the stack and the performance dropped to match the vector performance. Thanks, ipc, for keying me onto this.

相关问答

更多
  • 差异似乎是由于使用数组而不是std :: vector,我仍然很难相信。 我的两组代码如下所示,以供比较。 第一个可以从节目1以约2500MB / s的速率进行摄取。 第二个可以以3100MB / s的速率进行摄取。 计划1(2500 MB /秒) int main(int argc, char **argv) { int fd = open("/tmp/fifo2", O_RDONLY); std::vector buf(8*1024*1024); while(1) ...
  • 您错过的是在您阅读文件末尾之前未设置EOF 。 最后一次成功读取将读取(但不是过去)文件结尾,因此EOF为false , good()为true但流上没有更多数据(因此下一次读取将失败)。 这就是您需要检查流中的读取是否成功的原因。 为了在布尔上下文中使用流对象时(在/ if测试时),它将自身转换为boolean,该值是流的状态。 if (stream) { std::cout << "stream is in good state\n"; } 输入operator>>返回一个流(因此可以 ...
  • 你根本不能写这样的std::string ! 文件的内容可能包含您希望包含的字符(因为std::string可能使用小字符串优化)但是对于更大的字符串,它不会:您正在编写的std::string对象只是实际字符串的“控制记录”。 要编写std::string您可能会写两条信息: 要写入的std::string的长度。 std::string 。 操作看起来像这样: write(stream, s.size()); write(stream, s.c_str(), s.size()); (函数write() ...
  • 你真的确定将整个文件放入内存吗? 文件访问可以缓冲,但我怀疑你真的把整个文件放入内存。 我认为ifstream::read只是以更符合C ++的方式使用fread (因此是从C ++文件中读取二进制信息的标准方法)。 我怀疑是否存在显着的性能差异。 要使用fread ,必须打开文件。 它不只需要一个文件并立即将其放入内存。 所以ifstream::open == fopen和ifstream::read == fread 。 Are you really sure about fread putting t ...
  • 问题是,在读完出口后,会设置流failbit 。 只要它设置它就不会读取任何东西。 您将不得不调用std::istream::clear来清除错误。 顺便说一下,有一种更多的C ++ - ish方式来读入一个向量: std::copy(std::istream_iterator(inFile), std::istream_iterator(), std::back_inserter(vec)); 参考文献: std::copy std::istr ...
  • 流就像一个安全指针,它在文件上运行,并将它指向的值转换到某个目的地。 在GenericRead的最后,我怀疑流“指向”文件的末尾。 你需要将它回滚到文件的开头。 在Rule之前尝试fin.seekg(std::ifstream::beg) 。 免责声明 - 您没有发布整个代码,这只是我的(可靠的)假设。 a stream is like a safe-pointer which runs over the file and stream the value it points at at the momen ...
  • 速度和优化是每个项目的两个重要因素。 它们更依赖于程序员,而不依赖于语言或实现。 很多时候,当我们需要优化时,我们认为当前的语言或实现没有得到优化。 ifstream是C ++中的标准类,我认为QFile使用它。 您可以在定义的环境中描述和测量您想要测量的速度和比率,并且最好描述您面临的情况。 另一个重点,我无法理解为什么文件操作符类的速度对你很重要?! 许多文件相关的操作可以而且应该在内存中完成,并且硬盘的陷阱应该保持最小。 因此,在理想的情况下,我认为ifstream , QFile或任何较慢的文件访问 ...
  • 是否在程序开头一次读取所有数据比在程序期间通过std :: ifstream访问文件更快? 是的,可能是。 请记住,工作内存快速且昂贵,而存储内存(硬盘驱动器)的存在恰好以便宜而代价慢。 堆分配的“大”是什么? 操作系统将试图欺骗您的过程,使其认为所有现有的工作内存都是免费的。 实际上并非如此,如果某些进程请求太多内存,操作系统将为另一种“交换”一种类型的内存。 但原则上,如果堆分配与工作内存的总大小相当,则应该认为堆分配很大。 保持文件打开并使用文件操纵器是否比潜在的大堆分配和使用字符串操纵器更快? 不, ...
  • 如果在文本模式下打开文件流,则无效: is.seekg(start_position + static_cast(processed_chars)); ...因为根据标准, seekg / tellg与处理的字符数量没有直接关系(这实际上与操作系统有关)。 以下是可能的选项(无法提供您在问题中提供的更多详细信息): 使用putback来放回你读过但未使用的字符; 使用tellg来获得正确的位置。 这样的事情可能是: // is is the istream auto tg ...
  • 我想你想说: std::cout << " ifstream file size: " << fs.tellg().seekpos() << std::endl; 至少对于我已经铺设的6GB文件正常工作。 但是我正在使用Visual Studio 2012进行编译。即使您的原始代码在该环境下也能正常工作。 所以我怀疑这是VS 2010中std库中的一个bug,在VS 2012中得到了修复。无论是pos_type的运算符重载中的错误还是该类不是64位的,都是未知的。 我不得不安装VS 2010来验证,但这 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。