ContentPlaceHolder generates automatically width=100%
-
07-12-2019 - |
Question
in my custom master page the content doesn't fit into the page since a automatically generated table with the id=layoutsTable has width="100%". Since i have a fixed page layout there are some issues in the correct display.
Unfortunately this table is created automatically from the Control with id="PlaceHolderMain". I can't change this behaviour from the master-Layout neither in the .css-Page.
The parent div-container has the correct width but the table has this behaviour set instyle..
How can i change this instyle-Code or
La solution
Try the following CSS:
#layoutsTable
{
width: inherit !important;
}
The !important
flag usually works for me to even overwrite inline CSS styles.
Autres conseils
You can use the class s4-nosetwidth
to prevent SharePoint from taking over and injecting a variable width on the page. The best spot to do this is in the workspace div, but you can do it in other ones as well.
For example, you could just change this:
<div ID="s4-workspace">
To:
<div ID="s4-workspace" class="s4-nosetwidth">
Update:
Since the above solution is not applying directly to the generated table, you could always do this through javascript by adding this to your page:
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push('setLayoutsTableWidth');
function setLayoutsTableWidth() {
var layoutsTable = document.getElementById('layoutsTable');
layoutsTable.style.width = '200px';
}
</script>