0

我在 twitter bootstrap 的轮播示例中看到container marketingimg 和featuretteimg 是动态生成的。

我是css、javascript和twitter bootstrap的新手,谁能解释一下?我很想知道它是如何完成的,以便我可以更改它以生成我自己的图像,谢谢!

这是javascript(我想是的..它在holder.js):

var settings = {
    domain: "holder.js",
    images: "img",
    bgnodes: ".holderjs",
    themes: {
        "gray": {
            background: "#eee",
            foreground: "#aaa",
            size: 12
        },
        "social": {
            background: "#3a5a97",
            foreground: "#fff",
            size: 12
        },
        "industrial": {
            background: "#434A52",
            foreground: "#C2F200",
            size: 12
        }
    },
    stylesheet: ".holderjs-fluid {font-size:16px;font-weight:bold;text-align:center;font-family:sans-serif;margin:0}"
};

这是html部分:

  <div class="featurette">
    <img class="featurette-image img-circle pull-right" data-src="holder.js/512x512">
    <h2 class="featurette-heading">First featurette heading. <span class="text-muted">It'll blow your mind.</span></h2>
    <p class="lead">Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.</p>
  </div>

查看图像时,其地址如下所示:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAANwUlEQVR4nO3dbUtiexvG4f39P4oggQQRQQgiEkSEiIiISIiIyPoK1/1iHqppLbPZc8/s6TxeHK9GV/Vn4Pqt53+apikAIMs/f/oXAAB+PwEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACBBAAABBIAABBIAABAIAEAAIEEAAAEEgAAEEgAAEAgAQAAgQQAAAQSAAAQSAAAQCABAACB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ACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAv0PnVh7b3swf+IAAAAASUVORK5CYII=

编辑:

谢谢大家,解答!!正是由于您的所有回答,我才发现图像是从主题生成的:{ ... } in var settings

4

2 回答 2

1

您正在处理图像数据 URI,它们基本上只是文本格式的图像,它们不依赖于 CSS 或 JavaScript;它实际上只是以字符格式编码的图像数据。

您可以使用各种在线工具生成它们,例如此图像到数据 uri 转换器

使用它们的好处是可以将非常小的图像内联到 HTML,从而使浏览器免于发出无关的 HTTP 请求,并且如果您的 HTML 被很好地缓存,那么它也是一个痛苦的解决方案。请记住,它们也有其缺点:例如,它们对于大图像来说效率很低。

于 2013-08-06T16:44:57.090 回答
1

这只是 Data-URIs 图像:https ://developer.mozilla.org/en-US/docs/data_URIs

它们是直接以 URL 格式编码的图像,因此您无需从服务器请求它们。

您可以在此站点上测试将图像编译为 data-uri:http: //dataurl.net/#dataurlmaker

Sass 和 Compass 也有一个助手可以直接在样式表源 ( http://compass-style.org/reference/compass/helpers/inline-data/ ) 中利用编码。

于 2013-08-06T16:45:35.523 回答