简体   繁体   English

将标题移到div上方而不使用Javascript

[英]Move title above div without using Javascript

I am trying to make a element-builder (CMS) with which you can drag and drop elements into a page and easily create websites. 我正在尝试制作一个元素生成器(CMS),您可以使用该元素生成器将元素拖放到页面中并轻松创建网站。 I am using the bootstrap templates (css,js) to get a responsive website. 我正在使用引导程序模板(css,js)来获得响应式网站。

The problem is the following: 问题如下:

_col-md-4_______________________
|                               |
| Page Title                    |
|_______________________________|
|           |                   |
|Image      | (main content)    |
|           |                   |
|           |                   |
|div=col-xs-2___div=col-xs-10___|

My title must be aligned above the main content. 我的标题必须与主要内容对齐。

I tried to create a responsive result by using Javascript: 我试图使用Javascript创建响应结果:

<script>$(document).ready(function() {
    var witdh = $(\'.calculate-witdh\').innerWidth();
    $(".title-offset").each(function(){$(this).css(\'margin-left\', witdh)});
    });
    $(window).resize(function() {
    var witdh = $(\'.calculate-witdh\').innerWidth();
    $(".title-offset").each(function(){$(this).css(\'margin-left\', witdh)});
    });
    </script>

But I think there has to be a better solution? 但是我认为必须有更好的解决方案? Mainly because I don't want each element to load in it's own script. 主要是因为我不希望每个元素都加载到自己的脚本中。

Example found here: http://jsfiddle.net/abayob/vuskazh1/ 此处找到示例: http : //jsfiddle.net/abayob/vuskazh1/

Any ideas? 有任何想法吗?

Does this do what you want? 这是您想要的吗?

<h1 class="title-offset col-xs-offset-2">Create a title here</h1>

http://jsfiddle.net/abalter/mhqxtppn/ http://jsfiddle.net/abalter/mh​​qxtppn/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM