How set div´s width and height dynamically depending on the conent

时间:2017-12-18 07:46:20

标签: html css

I want to set the class GinSpaceConcatIndex(GinIndex): def get_sql_create_template_values(self, model, schema_editor, using): fields = [model._meta.get_field(field_name) for field_name, order in self.fields_orders] tablespace_sql = schema_editor._get_index_tablespace_sql(model, fields) quote_name = schema_editor.quote_name columns = [ ('%s %s' % (quote_name(field.column), order)).strip() for field, (field_name, order) in zip(fields, self.fields_orders) ] return { 'table': quote_name(model._meta.db_table), 'name': quote_name(self.name), 'columns': "({}) gin_trgm_ops".format(" || ' ' || ".join(columns)), 'using': using, 'extra': tablespace_sql, } div to dynamically change as I add content. Right now it takes up almost the whole screen because of the .editBokningar. How can I achive this the best way? The Snippet height is not accurate here. In the snippet the height stays close to the conent.

100%
    .EditBoking {
        width: 100%;
        height: 100%;
        margin: 15px 0px 15px 0px;
        background-color: #E1E777;
        border-radius: 10px;
        text-align: center;
        padding-top: 15px;
    }

    .title {
        font-weight: bold;
        color: #FF3333;
    }

    .listOneRow {
        display: inline-block;
        font-weight: bold;
    }
        ul {
        list-style-type: none;
        padding: 0;
    }

3 个答案:

答案 0 :(得分:2)

As EditBoking is div which is a block element, it is not necessary to define width: 100% as it will by default take up the whole space

But for your question,

just remove

.left {
  position: sticky;
  top: 0;
  align-self: flex-start;
}

from the code.

答案 1 :(得分:1)

Simply make your element inline-block and remove height/width property:

Root<Product> p = query.from(Product.class);
Path<Long> hitCount= p.<Long>get("hitCount");

//...

Order oder = getSortDirection() == 0 ? builder.asc(hitCount) : builder.desc(hitCount);  
query.orderBy(order); //NULLS LAST ?

//
.EditBoking {
  display:inline-block;
  margin: 15px 0px 15px 0px;
  background-color: #E1E777;
  border-radius: 10px;
  text-align: center;
  padding-top: 15px;
}

.title {
  font-weight: bold;
  color: #FF3333;
}

.listOneRow {
  display: inline-block;
  font-weight: bold;
}

ul {
  list-style-type: none;
  padding: 0;
}

答案 2 :(得分:1)

use display inline-block as below

table A
code | code_name | flag
EXE | Execute | Y
IMP | Implement| Y

table B
Year | phase | flag
2016 | P1 | Y
2016 | P2 | Y
2017 | P1 | Y
2017 | P2 | Y
2018 | P1 | N

table C
Status | Flag
EXE-2016 | Y
IMP-2016 | Y
EXE-2017 | Y
IMP-2017 | Y
EXE-2018 | N
IMP-2018 | N